From 36d96d2401b962dd0bb8f277fe486fda2d4422ba Mon Sep 17 00:00:00 2001 From: Masum ULU Date: Wed, 17 May 2023 21:32:11 +0300 Subject: [PATCH] fix condition line for error component --- .../src/lib/handlers/error.handler.ts | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/npm/ng-packs/packages/theme-shared/src/lib/handlers/error.handler.ts b/npm/ng-packs/packages/theme-shared/src/lib/handlers/error.handler.ts index 4f833fe0f1..adbbba4ddf 100644 --- a/npm/ng-packs/packages/theme-shared/src/lib/handlers/error.handler.ts +++ b/npm/ng-packs/packages/theme-shared/src/lib/handlers/error.handler.ts @@ -123,9 +123,11 @@ export class ErrorHandler { } private executeErrorHandler = (error: any) => { - const returnValue = this.httpErrorHandler(this.injector, error); + const errHandler = this.httpErrorHandler(this.injector, error); + const isObservable = errHandler instanceof Observable; + const response = isObservable ? errHandler : of(null); - return (returnValue instanceof Observable ? returnValue : of(null)).pipe( + return response.pipe( catchError(err => { this.handleError(err); return of(null); @@ -139,6 +141,11 @@ export class ErrorHandler { defaultValue: DEFAULT_ERROR_MESSAGES.defaultError.title, }; + if (err instanceof HttpErrorResponse && err.headers.get('Abp-Tenant-Resolve-Error')) { + this.authService.logout().subscribe(); + return; + } + if (err instanceof HttpErrorResponse && err.headers.get('_AbpErrorFormat')) { const confirmation$ = this.showErrorWithRequestBody(body); @@ -147,8 +154,6 @@ export class ErrorHandler { this.navigateToLogin(); }); } - } if(err instanceof HttpErrorResponse && err.headers.get('Abp-Tenant-Resolve-Error')){ - this.authService.logout().subscribe(); } else { switch (err.status) { case 401: @@ -178,7 +183,7 @@ export class ErrorHandler { status: 403, }); break; - case 404:{ + case 404: this.canCreateCustomError(404) ? this.show404Page() : this.showError( @@ -191,9 +196,7 @@ export class ErrorHandler { defaultValue: DEFAULT_ERROR_MESSAGES.defaultError404.title, }, ); - break; - } - + break; case 500: this.createErrorComponent({ title: {