Browse Source

fix condition line for error component

pull/16601/head
Masum ULU 3 years ago
parent
commit
36d96d2401
  1. 19
      npm/ng-packs/packages/theme-shared/src/lib/handlers/error.handler.ts

19
npm/ng-packs/packages/theme-shared/src/lib/handlers/error.handler.ts

@ -123,9 +123,11 @@ export class ErrorHandler {
} }
private executeErrorHandler = (error: any) => { 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 => { catchError(err => {
this.handleError(err); this.handleError(err);
return of(null); return of(null);
@ -139,6 +141,11 @@ export class ErrorHandler {
defaultValue: DEFAULT_ERROR_MESSAGES.defaultError.title, 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')) { if (err instanceof HttpErrorResponse && err.headers.get('_AbpErrorFormat')) {
const confirmation$ = this.showErrorWithRequestBody(body); const confirmation$ = this.showErrorWithRequestBody(body);
@ -147,8 +154,6 @@ export class ErrorHandler {
this.navigateToLogin(); this.navigateToLogin();
}); });
} }
} if(err instanceof HttpErrorResponse && err.headers.get('Abp-Tenant-Resolve-Error')){
this.authService.logout().subscribe();
} else { } else {
switch (err.status) { switch (err.status) {
case 401: case 401:
@ -178,7 +183,7 @@ export class ErrorHandler {
status: 403, status: 403,
}); });
break; break;
case 404:{ case 404:
this.canCreateCustomError(404) this.canCreateCustomError(404)
? this.show404Page() ? this.show404Page()
: this.showError( : this.showError(
@ -191,9 +196,7 @@ export class ErrorHandler {
defaultValue: DEFAULT_ERROR_MESSAGES.defaultError404.title, defaultValue: DEFAULT_ERROR_MESSAGES.defaultError404.title,
}, },
); );
break; break;
}
case 500: case 500:
this.createErrorComponent({ this.createErrorComponent({
title: { title: {

Loading…
Cancel
Save