Bug 1737269 - show error messages returned by server

This commit is contained in:
Sebastian Hengst 2021-10-22 15:00:41 +02:00
Родитель 164493c819
Коммит 7053a507ab
1 изменённых файлов: 9 добавлений и 4 удалений

Просмотреть файл

@ -45,18 +45,23 @@ export const formatTaskclusterError = function formatTaskclusterError(e) {
};
export const processErrorMessage = function processErrorMessage(error, status) {
let errorMessage = '';
if (status >= 500) {
return 'There was a problem retrieving the data. Please try again in a minute.';
errorMessage +=
'There was a problem retrieving the data. Please try again in a minute.';
}
if (status === 400) {
return 'The action resulted in a bad request.';
errorMessage += 'The action resulted in a bad request.';
}
if (error instanceof Object) {
const key = Object.keys(error);
return `${key}: ${error[key]}`;
errorMessage += ` ${key}: ${error[key]}`;
} else if (error) {
errorMessage += error;
}
return error;
return errorMessage ? errorMessage.trim() : error;
};