Skip to content

Commit 2433908

Browse files
committed
Handle custom theme errors nicely
1 parent 062f483 commit 2433908

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

packages/app/src/app/overmind/effects/vscode/initializers.ts

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import JSON5 from 'json5';
22
import codeSandboxTheme from '@codesandbox/common/lib/themes/codesandbox.json';
33
import codeSandboxBlackTheme from '@codesandbox/common/lib/themes/codesandbox-black';
4+
import { notificationState } from '@codesandbox/common/lib/utils/notifications';
5+
import { NotificationStatus } from '@codesandbox/notifications';
46

57
export function initializeThemeCache() {
68
try {
@@ -174,7 +176,25 @@ export function initializeCustomTheme() {
174176
const customTheme = localStorage.getItem('settings.manualCustomVSCodeTheme');
175177

176178
if (customTheme) {
177-
installCustomTheme('custom', 'Custom Theme', JSON.parse(customTheme));
179+
try {
180+
installCustomTheme('custom', 'Custom Theme', JSON.parse(customTheme));
181+
} catch (e) {
182+
notificationState.addNotification({
183+
title: 'Something went wrong while installing the custom extension',
184+
message: e.message,
185+
status: NotificationStatus.ERROR,
186+
actions: {
187+
primary: [
188+
{
189+
label: 'Clear Custom Theme',
190+
run: () => {
191+
localStorage.removeItem('settings.manualCustomVSCodeTheme');
192+
},
193+
},
194+
],
195+
},
196+
});
197+
}
178198
}
179199
}
180200

0 commit comments

Comments
 (0)