diff --git a/web/src/app/submissions/[submissionId]/_reviewButtons.tsx b/web/src/app/submissions/[submissionId]/_reviewButtons.tsx index a038d9e..fd51d73 100644 --- a/web/src/app/submissions/[submissionId]/_reviewButtons.tsx +++ b/web/src/app/submissions/[submissionId]/_reviewButtons.tsx @@ -15,13 +15,26 @@ interface ReviewId { submissionId: string } -function ReviewButtonClicked(action: Action, submissionId: string) { - fetch(`/api/submissions/${submissionId}/status/${action}`, { - method: "POST", - headers: { - "Content-type": "application/json", +async function ReviewButtonClicked(action: Action, submissionId: string) { + try { + const response = await fetch(`/api/submissions/${submissionId}/status/${action}`, { + method: "POST", + headers: { + "Content-type": "application/json", + } + }); + // Check if the HTTP request was successful + if (!response.ok) { + const errorDetails = await response.text(); + + // Throw an error with detailed information + throw new Error(`HTTP error! status: ${response.status}, details: ${errorDetails}`); } - }).then(() => { window.location.reload(); }) + + window.location.reload(); + } catch (error) { + console.error("Error updating submission status:", error); + } } function ReviewButton(props: ReviewButton) { diff --git a/web/src/app/submit/page.tsx b/web/src/app/submit/page.tsx index c562ad3..6f3c1b7 100644 --- a/web/src/app/submit/page.tsx +++ b/web/src/app/submit/page.tsx @@ -51,6 +51,14 @@ export default function SubmissionInfoPage() { body: JSON.stringify(payload), }); + // Check if the HTTP request was successful + if (!response.ok) { + const errorDetails = await response.text(); + + // Throw an error with detailed information + throw new Error(`HTTP error! status: ${response.status}, details: ${errorDetails}`); + } + // Allow any HTTP status const id_response:IdResponse = await response.json();