diff --git a/web2/src/lib/error.js b/web2/src/lib/error.js index 05b07560..26375fa9 100644 --- a/web2/src/lib/error.js +++ b/web2/src/lib/error.js @@ -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; }