[extension] Better error when submitting

This commit is contained in:
orosmatthew 2023-05-09 17:19:43 -04:00
parent 7df32c63d1
commit 05761d811e
2 changed files with 13 additions and 7 deletions

View File

@ -104,9 +104,8 @@ export class BWPanel {
data.value.teamId,
data.value.problemId
);
} catch (reason) {
vscode.window.showErrorMessage('Unable to submit');
console.error(reason);
} catch (err: any) {
vscode.window.showErrorMessage(err.message ?? 'Submission unsuccessful');
break;
}
vscode.window.showInformationMessage('Submitted!');
@ -135,8 +134,15 @@ export class BWPanel {
),
data.value.problemPascalName,
data.value.input
).then((output) => {
)
.then((output) => {
this._panel.webview.postMessage({ type: 'onOutput', value: output });
})
.catch(() => {
this._panel.webview.postMessage({
type: 'onOutput',
value: '[An error occurred while running]'
});
});
break;
}

View File

@ -58,6 +58,6 @@ export async function submitProblem(
throw Error('Failed to post submission');
}
if (!res.data.success) {
throw Error('Submission post unsuccessful');
throw Error(res.data.message ?? 'Unknown error');
}
}