From a6f4757a1703201a07d8adabc7e2afc3feb0114a Mon Sep 17 00:00:00 2001 From: EPortman Date: Tue, 13 Aug 2024 22:18:07 -0700 Subject: [PATCH] feat: add error handling when updating NR data --- app/package.json | 2 +- app/store/examine/index.ts | 21 +++++++++++---------- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/app/package.json b/app/package.json index fc74e4e0..3c3170bc 100644 --- a/app/package.json +++ b/app/package.json @@ -1,6 +1,6 @@ { "name": "name-examination", - "version": "1.2.30", + "version": "1.2.31", "private": true, "scripts": { "build": "nuxt generate", diff --git a/app/store/examine/index.ts b/app/store/examine/index.ts index 09beb9a4..50ef3c1f 100644 --- a/app/store/examine/index.ts +++ b/app/store/examine/index.ts @@ -817,7 +817,6 @@ export const useExamination = defineStore('examine', () => { // set reset flag so name data is managed between Namex and NRO correctly hasBeenReset.value = true await updateRequest() - await fetchAndLoadNr(nrNumber.value) } async function resetNr() { @@ -825,7 +824,6 @@ export const useExamination = defineStore('examine', () => { clearConsent() furnished.value = 'N' await updateRequest() - await fetchAndLoadNr(nrNumber.value) } async function claimNr() { @@ -900,15 +898,18 @@ export const useExamination = defineStore('examine', () => { } async function updateRequest() { - const data = await getNrData() - const response = await putNameRequest(nrNumber.value, data) - if (response.ok) { + try { + const data = await getNrData() + const response = await putNameRequest(nrNumber.value, data) + if (!response.ok) { + throw new Error('Failed to update NR') + } await parseNr(await response.json()) - } else { - emitter.emit('error', { - title: `Failed to update NR`, - message: `An error occurred while trying to update ${nrNumber.value}`, - }) + } catch { + emitter.emit('error', { + title: `Failed to update NR`, + message: `An error occurred while trying to update ${nrNumber.value}`, + }) await fetchAndLoadNr(nrNumber.value) } }