Skip to content

Commit fabea90

Browse files
committed
feat: improve error dialog when gist publish is failing
1 parent 28004bb commit fabea90

File tree

1 file changed

+19
-5
lines changed

1 file changed

+19
-5
lines changed

src/renderer/components/commands-action-button.tsx

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import { observer } from 'mobx-react';
1616
import {
1717
EditorId,
1818
EditorValues,
19+
GenericDialogType,
1920
GistActionState,
2021
GistActionType,
2122
PACKAGE_NAME,
@@ -156,11 +157,24 @@ export const GistActionButton = observer(
156157
} catch (error: any) {
157158
console.warn(`Could not publish gist`, { error });
158159

159-
window.ElectronFiddle.showWarningDialog({
160-
message:
161-
'Publishing Fiddle to GitHub failed. Are you connected to the Internet?',
162-
detail: `GitHub encountered the following error: ${error.message}`,
163-
});
160+
if (error.message.includes('Bad credentials')) {
161+
const { confirm } = await this.props.appState.showGenericDialog({
162+
label: `Publishing Fiddle to GitHub failed. Github encountered the following error: ${error.message}`,
163+
ok: 'Update token',
164+
cancel: 'Close',
165+
type: GenericDialogType.warning,
166+
wantsInput: false,
167+
});
168+
169+
if (confirm) {
170+
this.props.appState.toggleSettings();
171+
this.props.appState.isTokenDialogShowing = true;
172+
}
173+
} else {
174+
await this.props.appState.showErrorDialog(
175+
`Publishing Fiddle to GitHub failed. Are you connected to the Internet? GitHub encountered the following error: ${error.message}`,
176+
);
177+
}
164178

165179
return false;
166180
}

0 commit comments

Comments
 (0)