RED-3800 error-message.service.ts edited online with Bitbucket
This commit is contained in:
parent
2998cb076f
commit
83f2fbd88f
@ -6,7 +6,8 @@ import { HttpErrorResponse } from '@angular/common/http';
|
|||||||
providedIn: 'root',
|
providedIn: 'root',
|
||||||
})
|
})
|
||||||
export class ErrorMessageService {
|
export class ErrorMessageService {
|
||||||
constructor(private readonly _translateService: TranslateService) {}
|
constructor(private readonly _translateService: TranslateService) {
|
||||||
|
}
|
||||||
|
|
||||||
getMessage(error: HttpErrorResponse, defaultMessage?: string): string {
|
getMessage(error: HttpErrorResponse, defaultMessage?: string): string {
|
||||||
return defaultMessage
|
return defaultMessage
|
||||||
@ -15,8 +16,7 @@ export class ErrorMessageService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private _parseErrorResponse(err: HttpErrorResponse): string {
|
private _parseErrorResponse(err: HttpErrorResponse): string {
|
||||||
return err?.error?.message?.includes('"message":')
|
return (err?.error?.message?.match('"message":"(.*?)\\"')?.[0] as string ) || (err?.error?.message as string);
|
||||||
? ` ${err.error.message.match('"message":"(.*?)\\"')[1]}`
|
|
||||||
: (err?.error?.message as string);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user