Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

21893 Catch errors when updating NR data #1535

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading