Skip to content

Commit 1e9da33

Browse files
authored
Add try catch to error/correction resolving (codesandbox#2610)
* Add try catch to error/correction resolving * Fix typings
1 parent 8e70564 commit 1e9da33

File tree

2 files changed

+26
-22
lines changed

2 files changed

+26
-22
lines changed

packages/app/src/app/overmind/namespaces/editor/actions.ts

Lines changed: 23 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -374,13 +374,17 @@ export const prettifyClicked: AsyncAction = async ({
374374
export const errorsCleared: Action = ({ state }) => {
375375
if (state.editor.errors.length) {
376376
state.editor.errors.forEach(error => {
377-
const module = resolveModule(
378-
error.path,
379-
state.editor.currentSandbox.modules,
380-
state.editor.currentSandbox.directories
381-
);
382-
383-
module.errors = [];
377+
try {
378+
const module = resolveModule(
379+
error.path,
380+
state.editor.currentSandbox.modules,
381+
state.editor.currentSandbox.directories
382+
);
383+
module.errors = [];
384+
} catch (e) {
385+
// Module is probably somewhere in eg. /node_modules which is not
386+
// in the store
387+
}
384388
});
385389
state.editor.errors = [];
386390
}
@@ -575,13 +579,18 @@ export const previewActionReceived: Action<{
575579

576580
if (newCorrections.length !== currentCorrections.length) {
577581
state.editor.corrections.forEach(correction => {
578-
const module = resolveModule(
579-
correction.path,
580-
state.editor.currentSandbox.modules,
581-
state.editor.currentSandbox.directories
582-
);
583-
584-
module.corrections = [];
582+
try {
583+
const module = resolveModule(
584+
correction.path,
585+
state.editor.currentSandbox.modules,
586+
state.editor.currentSandbox.directories
587+
);
588+
589+
module.corrections = [];
590+
} catch (e) {
591+
// Module is probably in node_modules or something, which is not in
592+
// our store
593+
}
585594
});
586595
state.editor.corrections = newCorrections;
587596
}

standalone-packages/vscode-textmate/package-lock.json

Lines changed: 3 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)