Skip to content

Commit

Permalink
refactor(api): error message (#416)
Browse files Browse the repository at this point in the history
  • Loading branch information
ZonaHex authored Mar 18, 2024
1 parent 22d9959 commit 6dd3e35
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions src/api/interceptor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,9 @@ axios.interceptors.response.use(
// v1 and error
Message.error({
content: data.error || 'Error',
duration: 2 * 1000,
duration: 5 * 1000,
closable: true,
resetOnHover: true,
})
const error = {
error: data.error,
Expand All @@ -87,10 +89,17 @@ axios.interceptors.response.use(
const appStore = useAppStore()
appStore.updateSettings({ globalSettings: true })
}
const data = JSON.parse(error.response.data)
Message.error({
content: error.message || 'Request Error',
duration: 2 * 1000,
content: data.error || 'Request Error',
duration: 5 * 1000,
closable: true,
resetOnHover: true,
})
return Promise.reject(error)
const errorResponse = {
error: data.error,
startTime: new Date(error.response.config.traceTimeStart).toLocaleTimeString(),
}
return Promise.reject(errorResponse || error.message || 'Request Error')
}
)

0 comments on commit 6dd3e35

Please sign in to comment.