diff --git a/modules/ui/src/app/interceptors/error.interceptor.spec.ts b/modules/ui/src/app/interceptors/error.interceptor.spec.ts index bd8950993..7271223a2 100644 --- a/modules/ui/src/app/interceptors/error.interceptor.spec.ts +++ b/modules/ui/src/app/interceptors/error.interceptor.spec.ts @@ -50,7 +50,7 @@ describe('ErrorInterceptor', () => { expect(interceptor).toBeTruthy(); }); - it('should notify about backend errors', done => { + it('should notify about backend errors with message if exist', done => { const next: HttpHandler = { handle: () => { return throwError( @@ -61,6 +61,24 @@ describe('ErrorInterceptor', () => { const requestMock = new HttpRequest('GET', '/test'); + interceptor.intercept(requestMock, next).subscribe( + () => ({}), + () => { + expect(notificationServiceMock.notify).toHaveBeenCalledWith('error'); + done(); + } + ); + }); + + it('should notify about backend errors with default message', done => { + const next: HttpHandler = { + handle: () => { + return throwError(new HttpErrorResponse({ status: 500 })); + }, + }; + + const requestMock = new HttpRequest('GET', '/test'); + interceptor.intercept(requestMock, next).subscribe( () => ({}), () => { diff --git a/modules/ui/src/app/interceptors/error.interceptor.ts b/modules/ui/src/app/interceptors/error.interceptor.ts index cfa512a85..9e653895a 100644 --- a/modules/ui/src/app/interceptors/error.interceptor.ts +++ b/modules/ui/src/app/interceptors/error.interceptor.ts @@ -66,7 +66,8 @@ export class ErrorInterceptor implements HttpInterceptor { ); } else { this.notificationService.notify( - 'Something went wrong. Check the Terminal for details.' + error.error?.error || + 'Something went wrong. Check the Terminal for details.' ); console.error(error.error?.error || error.message); }