-
-
Notifications
You must be signed in to change notification settings - Fork 64
[fixes issue 201]: shows errors while running code in output #202
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -56,7 +56,8 @@ | |||||
| height: "30vh", | ||||||
| padding: "1rem", | ||||||
| }, | ||||||
| overflow: "auto", | ||||||
| })); | ||||||
|
|
||||||
| const WelcomeText = styled("span")(({ theme }) => ({ | ||||||
| color: theme.palette.text.primary, | ||||||
|
|
@@ -176,6 +177,10 @@ | |||||
| const data = await response.json(); | ||||||
| const submissionId = data["token"]; | ||||||
|
|
||||||
| const decodeFormat = (data) => { | ||||||
| return atob(data).split("\n"); | ||||||
| } | ||||||
|
||||||
|
|
||||||
| setTimeout(() => { | ||||||
| fetch( | ||||||
| `${judge0SubmitUrl}/${submissionId}?base64_encoded=true&fields=*`, | ||||||
|
|
@@ -190,13 +195,18 @@ | |||||
| .then((response) => response.json()) | ||||||
| .then((data) => { | ||||||
| if (!data.stdout) { | ||||||
| enqueueSnackbar("Please check the code", { variant: "error" }); | ||||||
| setOutput(data.message); | ||||||
| return; | ||||||
| if(data.stderr) { | ||||||
|
||||||
| if(data.stderr) { | |
| if (data.stderr) { |
Copilot
AI
Oct 11, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The else block assumes compile_output exists, but doesn't verify it. If both stderr and compile_output are null/undefined, this will cause an error when decodeFormat is called. Consider adding a check: else if (data.compile_output) and handle the case where neither exists.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
decodeFormatfunction doesn't handle null or undefined input. Whendata.stderrordata.compile_outputis null/undefined (which can happen with Judge0 API responses), callingatob(data)will throw an error. Add a guard to check ifdataexists before decoding:return data ? atob(data).split(\"\\n\") : [];