mirror of
https://github.com/semaphoreui/semaphore.git
synced 2024-11-24 22:06:43 +01:00
feat(fe): more suitable text for 401 error
This commit is contained in:
parent
948bb8d1c3
commit
cab1bd313d
@ -1,7 +1,21 @@
|
||||
// eslint-disable-next-line import/prefer-default-export
|
||||
export function getErrorMessage(err) {
|
||||
if (err.response && err.response.data) {
|
||||
return err.response.data.error || err.message;
|
||||
if (err.response) {
|
||||
if (err.response.data && err.response.data.error) {
|
||||
return err.response.data.error;
|
||||
}
|
||||
|
||||
if (err.message && !err.message.startsWith('Request failed with status code ')) {
|
||||
return err.message;
|
||||
}
|
||||
|
||||
switch (err.response.status) {
|
||||
case 401:
|
||||
return `${err.response.status} ${err.response.statusText}`;
|
||||
default:
|
||||
return err.message;
|
||||
}
|
||||
}
|
||||
|
||||
return err.message;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user