From 590cd0a37c46f0b7feaac3d69e2181f282758970 Mon Sep 17 00:00:00 2001 From: cshowalter Date: Mon, 16 May 2022 14:04:57 -0700 Subject: [PATCH] Updated Error. --- .../app/core/interceptors/error.interceptor.ts | 5 +++-- .../server-error/server-error.component.html | 16 +++++++++++++++- .../core/server-error/server-error.component.ts | 7 ++++++- 3 files changed, 24 insertions(+), 4 deletions(-) diff --git a/client/src/app/core/interceptors/error.interceptor.ts b/client/src/app/core/interceptors/error.interceptor.ts index 867d867..2ec41e4 100644 --- a/client/src/app/core/interceptors/error.interceptor.ts +++ b/client/src/app/core/interceptors/error.interceptor.ts @@ -6,7 +6,7 @@ import { HttpInterceptor } from '@angular/common/http'; import { catchError, Observable, throwError } from 'rxjs'; -import { Router } from '@angular/router'; +import { NavigationExtras, Router } from '@angular/router'; import { ToastrService } from 'ngx-toastr'; @Injectable() @@ -37,7 +37,8 @@ export class ErrorInterceptor implements HttpInterceptor { } if (error.status === 500){ - this.router.navigateByUrl('/server-error'); + const navigationExtras: NavigationExtras = {state: {error: error.error}}; + this.router.navigateByUrl('/server-error', navigationExtras); } } return throwError(() => new Error(error)); diff --git a/client/src/app/core/server-error/server-error.component.html b/client/src/app/core/server-error/server-error.component.html index 95017c1..d301fcb 100644 --- a/client/src/app/core/server-error/server-error.component.html +++ b/client/src/app/core/server-error/server-error.component.html @@ -1,3 +1,17 @@
-

Internal Server Error

+

Server Internal Error - Refreshing the page clears the exception

+ +
{{e.message}}
+

Note: if you are seeing this, this is not a client side error.

+

What's next?

+
    +
  1. Open Chrom Dev Tools
  2. +
  3. Inspect the Network Tab
  4. +
  5. Check the failing request
  6. +
  7. Examin the request URL. Is it correct?
  8. +
  9. Reproduce Error in Postman
  10. +
+

Following is the stack trace - This is where your investigation begins.

+ {{e.details}} +
diff --git a/client/src/app/core/server-error/server-error.component.ts b/client/src/app/core/server-error/server-error.component.ts index bc3f70f..d643d5f 100644 --- a/client/src/app/core/server-error/server-error.component.ts +++ b/client/src/app/core/server-error/server-error.component.ts @@ -1,4 +1,5 @@ import { Component, OnInit } from '@angular/core'; +import { Router } from '@angular/router'; @Component({ selector: 'app-server-error', @@ -6,8 +7,12 @@ import { Component, OnInit } from '@angular/core'; styleUrls: ['./server-error.component.scss'] }) export class ServerErrorComponent implements OnInit { + e: any; - constructor() { } + constructor(private router: Router) { + const navigation = this.router.getCurrentNavigation(); + this.e = navigation?.extras?.state?.error; + } ngOnInit(): void { }