debian-mirror-gitlab/app/assets/javascripts/lib/utils/error_message.js

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

21 lines
512 B
JavaScript
Raw Normal View History

2023-05-27 22:25:52 +05:30
export const USER_FACING_ERROR_MESSAGE_PREFIX = 'UF:';
const getMessageFromError = (error = '') => {
return error.message || error;
};
export const parseErrorMessage = (error = '') => {
const messageString = getMessageFromError(error);
if (messageString.startsWith(USER_FACING_ERROR_MESSAGE_PREFIX)) {
return {
message: messageString.replace(USER_FACING_ERROR_MESSAGE_PREFIX, '').trim(),
userFacing: true,
};
}
return {
message: messageString,
userFacing: false,
};
};