Browse Source

update: http error handling page

pull/23285/head
sumeyye 1 year ago
parent
commit
5392715eb5
  1. 55
      docs/en/framework/ui/angular/http-error-handling.md

55
docs/en/framework/ui/angular/http-error-handling.md

@ -5,25 +5,25 @@
ABP offers a configurations for errors handling like below ABP offers a configurations for errors handling like below
```ts ```ts
import { ThemeSharedModule } from '@abp/ng.theme.shared'; //app.config.ts
import { MyCustomRouteErrorComponent } from './my-custom-route.component'; import { provideAbpThemeShared } from '@abp/ng.theme.shared';
import { CustomErrorComponent } from './custom-error.component';
@NgModule({ export const appConfig: ApplicationConfig = {
imports: [ providers: [
ThemeSharedModule.forRoot({ provideAbpThemeShared(
httpErrorConfig: { withHttpErrorConfig({
skipHandledErrorCodes: [403], skipHandledErrorCodes: [403],
errorScreen: { errorScreen: {
forWhichErrors: [404],
component: CustomErrorComponent, component: CustomErrorComponent,
hideCloseIcon: false forWhichErrors: [404],
} hideCloseIcon: false,
} },
}), }),
... ),
], ],
}) };
export class AppModule {}
``` ```
- `ErrorScreenErrorCodes` the error codes that you can pass to `skipHandledErrorCodes` and `forWhichErrors`. - `ErrorScreenErrorCodes` the error codes that you can pass to `skipHandledErrorCodes` and `forWhichErrors`.
@ -67,22 +67,19 @@ export function handleHttpErrors(injector: Injector, httpError: HttpErrorRespons
return of(httpError); return of(httpError);
} }
// app.module.ts // app.config.ts
import { Error404Component } from './error404/error404.component'; import { Error404Component } from './error404/error404.component';
import { handleHttpErrors } from './http-error-handling'; import { handleHttpErrors } from './http-error-handling';
import { HTTP_ERROR_HANDLER, ... } from '@abp/ng.theme.shared'; import { HTTP_ERROR_HANDLER, ... } from '@abp/ng.theme.shared';
@NgModule({ export const appConfig: ApplicationConfig = {
// ...
providers: [ providers: [
// ... ...
{ provide: HTTP_ERROR_HANDLER, useValue: handleHttpErrors } { provide: HTTP_ERROR_HANDLER, useValue: handleHttpErrors },
...
], ],
declarations: [ };
//...
Error404Component],
})
export class AppModule {}
``` ```
In the example above: In the example above:
@ -199,18 +196,16 @@ export class MyCustomErrorHandlerService
import { CUSTOM_ERROR_HANDLERS, ... } from '@abp/ng.theme.shared'; import { CUSTOM_ERROR_HANDLERS, ... } from '@abp/ng.theme.shared';
import { MyCustomErrorHandlerService } from './custom-error-handler.service'; import { MyCustomErrorHandlerService } from './custom-error-handler.service';
@NgModule({ export const appConfig: ApplicationConfig = {
// ...
providers: [ providers: [
// ... //...
{ {
provide: CUSTOM_ERROR_HANDLERS, provide: CUSTOM_ERROR_HANDLERS,
useExisting: MyCustomErrorHandlerService, useExisting: MyCustomErrorHandlerService,
multi: true, multi: true,
} }
] ],
}) };
export class AppModule {}
``` ```
In the example above: In the example above:

Loading…
Cancel
Save