debian-mirror-gitlab/app/assets/javascripts/lib/utils/error_message.js
2023-05-27 22:25:52 +05:30

20 lines
512 B
JavaScript

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,
};
};