1
0
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:
Sebastian Malton 2021-04-08 19:06:34 -04:00
parent e7df294b6e
commit a7093d962a
2 changed files with 10 additions and 12 deletions

View File

@ -269,14 +269,12 @@ export async function attemptInstallByInfo({ name, version, requireConfirmation
const disposer = ExtensionInstallationStateStore.startPreInstall(); const disposer = ExtensionInstallationStateStore.startPreInstall();
const registryUrl = new URLParse("https://registry.npmjs.com").set("pathname", name).toString(); const registryUrl = new URLParse("https://registry.npmjs.com").set("pathname", name).toString();
const { promise } = downloadJson({ url: registryUrl }); 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 { Notifications.error(`Failed to get registry information for that extension${message}`);
json = await promise;
} catch (error) {
console.error(error);
Notifications.error("Failed to get registry information for that extension");
return disposer(); return disposer();
} }

View File

@ -19,11 +19,10 @@ export interface ConfirmDialogParams extends ConfirmDialogBooleanParams {
export interface ConfirmDialogBooleanParams { export interface ConfirmDialogBooleanParams {
labelOk?: ReactNode; labelOk?: ReactNode;
labelCancel?: ReactNode; labelCancel?: ReactNode;
message?: ReactNode; message: ReactNode;
icon?: ReactNode; icon?: ReactNode;
okButtonProps?: Partial<ButtonProps> okButtonProps?: Partial<ButtonProps>;
cancelButtonProps?: Partial<ButtonProps> cancelButtonProps?: Partial<ButtonProps>;
} }
@observer @observer
@ -48,15 +47,16 @@ export class ConfirmDialog extends React.Component<ConfirmDialogProps> {
}); });
} }
public defaultParams: ConfirmDialogParams = { static defaultParams: Partial<ConfirmDialogParams> = {
ok: noop, ok: noop,
cancel: noop,
labelOk: "Ok", labelOk: "Ok",
labelCancel: "Cancel", labelCancel: "Cancel",
icon: <Icon big material="warning"/>, icon: <Icon big material="warning"/>,
}; };
get params(): ConfirmDialogParams { get params(): ConfirmDialogParams {
return Object.assign({}, this.defaultParams, ConfirmDialog.params); return Object.assign({}, ConfirmDialog.defaultParams, ConfirmDialog.params);
} }
ok = async () => { ok = async () => {