forked from vikunja/frontend
chore: provide better error messages when refreshing user info fails
This commit is contained in:
parent
33798b8d88
commit
d5358793de
@ -13,8 +13,14 @@ export function getErrorText(r): string {
|
||||
return message
|
||||
}
|
||||
}
|
||||
|
||||
let message = data?.message || r.message
|
||||
|
||||
if (typeof r.cause?.message !== 'undefined') {
|
||||
message += ' ' + r.cause.message
|
||||
}
|
||||
|
||||
return data?.message || r.message
|
||||
return message
|
||||
}
|
||||
|
||||
export interface Action {
|
||||
|
@ -296,7 +296,16 @@ export const useAuthStore = defineStore('auth', () => {
|
||||
logout()
|
||||
return
|
||||
}
|
||||
throw new Error('Error while refreshing user info:', {cause: e})
|
||||
|
||||
const cause = {e}
|
||||
|
||||
if (typeof e?.response?.data?.message !== 'undefined') {
|
||||
cause.message = e.response.data.message
|
||||
}
|
||||
|
||||
console.error('Error refreshing user info:', e)
|
||||
|
||||
throw new Error('Error while refreshing user info:', {cause})
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user