chore: provide better error messages when refreshing user info fails

This commit is contained in:
kolaente 2023-07-10 12:20:24 +02:00
parent 33798b8d88
commit d5358793de
Signed by untrusted user: konrad
GPG Key ID: F40E70337AB24C9B
2 changed files with 17 additions and 2 deletions

View File

@ -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 {

View File

@ -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})
}
}