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

View File

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