Skip to content

Commit 0f0701b

Browse files
authored
Merge pull request #203 from Prathamesh0901/main
[fixes issue 201]: added errors in output
2 parents 9ad82d1 + 0f38d67 commit 0f0701b

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

src/pages/EditorComponent.js

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,10 @@ const WelcomeText = styled("span")(({ theme }) => ({
6464
fontWeight: "bold",
6565
}));
6666

67+
const decodeFormat = (data) => {
68+
return data ? atob(data).split("\n") : [];
69+
}
70+
6771
function EditorComponent() {
6872
const [code, setCode] = useState(null);
6973
const [output, setOutput] = useState([]);
@@ -192,12 +196,14 @@ function EditorComponent() {
192196
.then((data) => {
193197
if (!data.stdout) {
194198
enqueueSnackbar("Please check the code", { variant: "error" });
195-
setOutput(data.message);
199+
if (data.stderr) {
200+
setOutput(decodeFormat(data.stderr));
201+
} else if (data.compile_output) {
202+
setOutput(decodeFormat(data.compile_output));
203+
}
196204
return;
197205
}
198-
const decodedOutput = atob(data.stdout);
199-
const formattedData = decodedOutput.split("\n");
200-
setOutput(formattedData);
206+
setOutput(decodeFormat(data.stdout));
201207
})
202208
.catch((error) => {
203209
enqueueSnackbar("Error retrieving output: " + error.message, {

0 commit comments

Comments
 (0)