Client - display info and errors on workout edition
This commit is contained in:
@ -17,8 +17,7 @@ export const getApiUrl = (): string => {
|
||||
// TODO: update api error messages to remove these workarounds
|
||||
const removeLastEndOfLine = (text: string): string => text.replace(/\n$/gm, '')
|
||||
const removeLastDot = (text: string): string => text.replace(/\.$/gm, '')
|
||||
const removeErrorDot = (text: string): string =>
|
||||
text.replace(/^Error\./gm, 'Error,')
|
||||
const replaceInternalDots = (text: string): string => text.replace(/\./gm, ',')
|
||||
|
||||
export const handleError = (
|
||||
context:
|
||||
@ -33,14 +32,16 @@ export const handleError = (
|
||||
let errorMessages = !error
|
||||
? msg
|
||||
: error.response
|
||||
? error.response.data.message
|
||||
? error.response.status === 413
|
||||
? 'File size is greater than the allowed size'
|
||||
: error.response.data.message
|
||||
? error.response.data.message
|
||||
: msg
|
||||
: error.message
|
||||
? error.message
|
||||
: msg
|
||||
errorMessages = removeLastEndOfLine(errorMessages)
|
||||
errorMessages = removeErrorDot(errorMessages)
|
||||
errorMessages = replaceInternalDots(errorMessages)
|
||||
context.commit(
|
||||
ROOT_STORE.MUTATIONS.SET_ERROR_MESSAGES,
|
||||
errorMessages.includes('\n')
|
||||
|
Reference in New Issue
Block a user