Skip to content

Commit

Permalink
feat: add error handling when updating NR data
Browse files Browse the repository at this point in the history
  • Loading branch information
EPortman authored Aug 15, 2024
1 parent 773bc1b commit 038580d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
2 changes: 1 addition & 1 deletion app/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "name-examination",
"version": "1.2.30",
"version": "1.2.31",
"private": true,
"scripts": {
"build": "nuxt generate",
Expand Down
21 changes: 11 additions & 10 deletions app/store/examine/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -817,15 +817,13 @@ 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() {
resetNrDecision()
clearConsent()
furnished.value = 'N'
await updateRequest()
await fetchAndLoadNr(nrNumber.value)
}

async function claimNr() {
Expand Down Expand Up @@ -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)
}
}
Expand Down

0 comments on commit 038580d

Please sign in to comment.