File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -92,21 +92,19 @@ export class ErrorHandlerInterceptor implements HttpInterceptor {
9292 : nestedMessage
9393 : topLevelMessage ;
9494 let parameterName : string | null = null ;
95- if ( response . error . errors ) {
96- if ( response . error . errors [ 0 ] ) {
97- if (
98- response . error . errors [ 0 ] . userMessageGlobalisationCode &&
99- this . databaseErrorCodes . indexOf ( response . error . errors [ 0 ] . userMessageGlobalisationCode ) > - 1
100- ) {
101- errorMessage = this . translate . instant ( 'errors.error.msg.data.integrity.issue' ) ;
102- } else {
103- errorMessage =
104- response . error . errors [ 0 ] . defaultUserMessage . replace ( / \\ ./ g, ' ' ) ||
105- response . error . errors [ 0 ] . developerMessage . replace ( / \\ ./ g, ' ' ) ;
106- }
95+ if ( errorBody ?. errors ?. [ 0 ] ) {
96+ const firstError = errorBody . errors [ 0 ] ;
97+ if (
98+ firstError . userMessageGlobalisationCode &&
99+ this . databaseErrorCodes . indexOf ( firstError . userMessageGlobalisationCode ) > - 1
100+ ) {
101+ errorMessage = this . translate . instant ( 'errors.error.msg.data.integrity.issue' ) ;
102+ } else {
103+ errorMessage =
104+ firstError . defaultUserMessage ?. replace ( / \. / g, ' ' ) || firstError . developerMessage ?. replace ( / \. / g, ' ' ) ;
107105 }
108- if ( 'parameterName' in errorBody . errors [ 0 ] ) {
109- parameterName = errorBody . errors [ 0 ] . parameterName ;
106+ if ( 'parameterName' in firstError ) {
107+ parameterName = firstError . parameterName ;
110108 }
111109 }
112110 const isClientImage404 = status === 404 && request . url . includes ( '/clients/' ) && request . url . includes ( '/images' ) ;
You can’t perform that action at this time.
0 commit comments