mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
display error when registry returns not found as JSON
Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
parent
e7df294b6e
commit
a7093d962a
@ -269,14 +269,12 @@ export async function attemptInstallByInfo({ name, version, requireConfirmation
|
||||
const disposer = ExtensionInstallationStateStore.startPreInstall();
|
||||
const registryUrl = new URLParse("https://registry.npmjs.com").set("pathname", name).toString();
|
||||
const { promise } = downloadJson({ url: registryUrl });
|
||||
const json = await promise.catch(console.error);
|
||||
|
||||
let json;
|
||||
if (!json || json.error || typeof json.values !== "object" || !json.values) {
|
||||
const message = json?.error ? `: ${json.error}` : "";
|
||||
|
||||
try {
|
||||
json = await promise;
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
Notifications.error("Failed to get registry information for that extension");
|
||||
Notifications.error(`Failed to get registry information for that extension${message}`);
|
||||
|
||||
return disposer();
|
||||
}
|
||||
|
||||
@ -19,11 +19,10 @@ export interface ConfirmDialogParams extends ConfirmDialogBooleanParams {
|
||||
export interface ConfirmDialogBooleanParams {
|
||||
labelOk?: ReactNode;
|
||||
labelCancel?: ReactNode;
|
||||
message?: ReactNode;
|
||||
message: ReactNode;
|
||||
icon?: ReactNode;
|
||||
okButtonProps?: Partial<ButtonProps>
|
||||
cancelButtonProps?: Partial<ButtonProps>
|
||||
|
||||
okButtonProps?: Partial<ButtonProps>;
|
||||
cancelButtonProps?: Partial<ButtonProps>;
|
||||
}
|
||||
|
||||
@observer
|
||||
@ -48,15 +47,16 @@ export class ConfirmDialog extends React.Component<ConfirmDialogProps> {
|
||||
});
|
||||
}
|
||||
|
||||
public defaultParams: ConfirmDialogParams = {
|
||||
static defaultParams: Partial<ConfirmDialogParams> = {
|
||||
ok: noop,
|
||||
cancel: noop,
|
||||
labelOk: "Ok",
|
||||
labelCancel: "Cancel",
|
||||
icon: <Icon big material="warning"/>,
|
||||
};
|
||||
|
||||
get params(): ConfirmDialogParams {
|
||||
return Object.assign({}, this.defaultParams, ConfirmDialog.params);
|
||||
return Object.assign({}, ConfirmDialog.defaultParams, ConfirmDialog.params);
|
||||
}
|
||||
|
||||
ok = async () => {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user