Skip to content

[fixes issue 201]: shows errors while running code in output#202

Closed
Prathamesh0901 wants to merge 4 commits into
DhanushNehru:mainfrom
Prathamesh0901:prathamesh
Closed

[fixes issue 201]: shows errors while running code in output#202
Prathamesh0901 wants to merge 4 commits into
DhanushNehru:mainfrom
Prathamesh0901:prathamesh

Conversation

@Prathamesh0901
Copy link
Copy Markdown
Contributor

Resolves #[Issue Number if there]

PR Fixes:

Checklist before requesting a review

  • I have pull latest changes from main branch
  • I have tested the changes locally
  • I have run npm run lint:fix locally
  • I have performed a self-review of my code
  • I assure there is no similar/duplicate pull request regarding same issue

Currently, there are no compilation or output errors shown in the editor. The only thing is a snackbar which is generic, the judge0 api provides compilation or any errors in the api, I have added them in the output section.

Current

image

Modified

image

@vercel
Copy link
Copy Markdown

vercel Bot commented Oct 11, 2025

@Prathamesh0901 is attempting to deploy a commit to the Dhanush Nehru's projects Team on Vercel.

A member of the Team first needs to authorize it.

@Prathamesh0901 Prathamesh0901 changed the title [fixes issue ]: shows errors while running code in output [fixes issue 201]: shows errors while running code in output Oct 11, 2025
@vercel
Copy link
Copy Markdown

vercel Bot commented Oct 11, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
custom-code-editor Ready Ready Preview Comment Oct 11, 2025 7:05am

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR enhances error reporting in the code editor by displaying compilation errors and stderr output in the output panel instead of just showing a generic snackbar notification. The changes extract error details from the Judge0 API response (stderr and compile_output) and display them in a user-friendly format.

Key changes:

  • Added auto-scrolling to the output panel for better visibility of long error messages
  • Refactored output decoding logic into a reusable function
  • Enhanced error handling to differentiate between runtime errors (stderr) and compilation errors (compile_output)

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment thread src/pages/EditorComponent.js Outdated
const submissionId = data["token"];

const decodeFormat = (data) => {
return atob(data).split("\n");
Copy link

Copilot AI Oct 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The decodeFormat function doesn't handle null or undefined input. When data.stderr or data.compile_output is null/undefined (which can happen with Judge0 API responses), calling atob(data) will throw an error. Add a guard to check if data exists before decoding: return data ? atob(data).split(\"\\n\") : [];

Suggested change
return atob(data).split("\n");
return data ? atob(data).split("\n") : [];

Copilot uses AI. Check for mistakes.
Comment thread src/pages/EditorComponent.js Outdated
enqueueSnackbar("Please check the code", { variant: "error" });
setOutput(data.message);
return;
if(data.stderr) {
Copy link

Copilot AI Oct 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing space after 'if' keyword. Should be if (data.stderr) to maintain consistent code formatting throughout the file.

Suggested change
if(data.stderr) {
if (data.stderr) {

Copilot uses AI. Check for mistakes.
Comment thread src/pages/EditorComponent.js Outdated
Comment on lines 198 to 208
if(data.stderr) {
enqueueSnackbar("Please check the code", { variant: "error" });
setOutput(decodeFormat(data.stderr));
return;
}
else {
enqueueSnackbar("Please check the code", { variant: "error" });
setOutput(decodeFormat(data.compile_output));
return;
}
}
Copy link

Copilot AI Oct 11, 2025

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.

Copilot uses AI. Check for mistakes.
@DhanushNehru
Copy link
Copy Markdown
Owner

Please solve the lint and copilot issues @Prathamesh0901

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 1 comment.


Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment on lines +180 to +182
const decodeFormat = (data) => {
return data?atob(data).split("\n"):[];
}
Copy link

Copilot AI Oct 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The decodeFormat function is defined inside the async callback function, causing it to be recreated on every code execution. Consider moving this function outside the runCode function or to the top level of the component to avoid unnecessary function recreation.

Copilot uses AI. Check for mistakes.
@Prathamesh0901 Prathamesh0901 deleted the prathamesh branch October 11, 2025 08:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants