Skip to content

Commit

Permalink
Merge pull request #334 from codescalers/development_1.1_fix_unwrap
Browse files Browse the repository at this point in the history
Fix error was not displayed
  • Loading branch information
MohamedElmdary authored Feb 1, 2024
2 parents 2ec311f + 064bb3b commit 1071ef1
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
15 changes: 7 additions & 8 deletions client/src/clients/api/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,12 @@ export abstract class ApiClientBase {
}

private static normalizeError(err: AxiosError<any>): string {
const responseData = err.response?.data
const errorMessage = responseData?.message ?? err.message

const errorDetails = Object.entries(responseData?.error || {})
.map(([_, value]) => `${value}`)
.join('. ')

return `${errorMessage}${errorDetails ? `. ${capitalize(errorDetails)}` : ''}`
return (
err.response?.data?.error?.message ||
err.response?.data?.detail ||
err.response?.data.message ||
err.message
)
}

protected async unwrap<T, R = T>(
Expand Down Expand Up @@ -98,6 +96,7 @@ export abstract class ApiClientBase {
}

if (
res &&
(res.config.method === 'post' || res.config.method === 'put') &&
typeof res.data === 'object' &&
'message' in (res.data || {}) &&
Expand Down
5 changes: 4 additions & 1 deletion client/src/components/NotificationDetailsDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,10 @@ export default {
return undefined
},
undefined,
{ immediate: false }
{
immediate: false,
onError: closeDialog
}
)
watch(
Expand Down

0 comments on commit 1071ef1

Please sign in to comment.