Skip to content

Commit

Permalink
feat: error handling for share link
Browse files Browse the repository at this point in the history
  • Loading branch information
yongenaelf committed Nov 17, 2024
1 parent 8f2f2c8 commit 9df48f6
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions components/workspace/use-cli-commands.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -310,12 +310,15 @@ export function useCliCommands() {
method: "POST",
body: JSON.stringify({ files }),
});
const { id } = await res.json();
const { id, error } = await res.json();

if (error || !id)
throw new Error(error);

terminalContext.setBufferedContent(<ShareLink id={id} />);
} catch (err) {
if (err instanceof Error)
terminalContext.setBufferedContent(<>{err.message}</>);
terminalContext.setBufferedContent(<p>{err.message?.trim() || "There was an error generating the share link. Please try again later."}</p>);
return;
}
},
Expand Down

0 comments on commit 9df48f6

Please sign in to comment.