Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const appRoutes: Routes = [
- {
- path: 'internal-server-error',
- component: InternalServerErrorComponent
- },
- {
- path: 'login',
- component: LoginComponent
- },
- {
- path: 'locked',
- component: LockedComponent
- },
- {
- path: 'weather',
- component: WeatherComponent
- },
- {
- path: '',
- component: AppComponent,
- canActivate: [AuthGuard],
- children:
- [
- {
- path: 'dashboard',
- component: DashboardComponent,
- data: { title: 'Dashboard' }
- },
- {
- path: 'mail',
- component: MailComponent,
- data: { title: 'Mail' }
- },
- {
- path: 'calendar',
- component: CalendarComponent,
- data: { title: 'Calendar' }
- },
- {
- path: '',
- redirectTo: '/dashboard',
- pathMatch: 'full'
- }
- ]
- },
- {
- path: '**',
- component: NotFoundComponent
- },
- ];
- // Error handling
- let amountOfErrors:number = 0;
- @Injectable()
- class MyErrorHandler implements ErrorHandler {
- injector: Injector;
- constructor(injector:Injector){
- this.injector = injector;
- }
- handleError(error) {
- amountOfErrors++;
- console.log("Amount of errors", amountOfErrors);
- console.log("MY ERROR", error);
- // Otherwise, this will cause an infinite loop
- if(amountOfErrors == 1){
- this.injector.get(Router).navigateByUrl("/internal-server-error").then(function(data){
- console.log("500 THEN:", data);
- });
- }
- }
- }
Add Comment
Please, Sign In to add comment