Skip to content

Commit 86f8c8b

Browse files
committed
Handle errors in external forks
1 parent 892d40e commit 86f8c8b

File tree

1 file changed

+17
-4
lines changed
  • packages/app/src/app/overmind/namespaces/editor

1 file changed

+17
-4
lines changed

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

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -507,13 +507,26 @@ export const forkExternalSandbox: AsyncAction<{
507507
sandboxId: string;
508508
openInNewWindow?: boolean;
509509
body?: { collectionId: string };
510-
}> = async ({ effects, state }, { sandboxId, openInNewWindow, body }) => {
510+
}> = async (
511+
{ effects, state, actions },
512+
{ sandboxId, openInNewWindow, body }
513+
) => {
511514
effects.analytics.track('Fork Sandbox', { type: 'external' });
512515

513-
const forkedSandbox = await effects.api.forkSandbox(sandboxId, body);
516+
try {
517+
const forkedSandbox = await effects.api.forkSandbox(sandboxId, body);
518+
519+
state.editor.sandboxes[forkedSandbox.id] = forkedSandbox;
520+
effects.router.updateSandboxUrl(forkedSandbox, { openInNewWindow });
521+
} catch (error) {
522+
console.error(error);
523+
actions.internal.handleError({
524+
message: 'We were unable to fork the sandbox',
525+
error,
526+
});
514527

515-
state.editor.sandboxes[forkedSandbox.id] = forkedSandbox;
516-
effects.router.updateSandboxUrl(forkedSandbox, { openInNewWindow });
528+
throw error;
529+
}
517530
};
518531

519532
export const forkSandboxClicked: AsyncAction = async ({

0 commit comments

Comments
 (0)