Skip to content

Commit 9b9742b

Browse files
author
anishfyle
committed
PR Comments
1 parent 3a0158d commit 9b9742b

File tree

4 files changed

+11
-63
lines changed

4 files changed

+11
-63
lines changed

src/app/app.module.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ import { SharedModule } from './shared/shared.module';
1818
import { RippleModule } from 'primeng/ripple';
1919
import { BrandingService } from './core/services/common/branding.service';
2020
import { Sage300ConfigurationModule } from './integrations/sage300/sage300-main/sage300-configuration/sage300-configuration.module';
21-
import { HttpErrorInterceptor } from './core/interceptor/http-error.interceptor';
2221

2322
@NgModule({
2423
declarations: [
@@ -47,11 +46,6 @@ import { HttpErrorInterceptor } from './core/interceptor/http-error.interceptor'
4746
useClass: JwtInterceptor,
4847
multi: true
4948
},
50-
{
51-
provide: HTTP_INTERCEPTORS,
52-
useClass: HttpErrorInterceptor,
53-
multi: true
54-
},
5549
{
5650
provide: ErrorHandler,
5751
useClass: GlobalErrorHandler

src/app/core/interceptor/http-error.interceptor.spec.ts

Lines changed: 0 additions & 16 deletions
This file was deleted.

src/app/core/interceptor/http-error.interceptor.ts

Lines changed: 0 additions & 36 deletions
This file was deleted.

src/app/core/services/common/api.service.ts

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,18 @@ export class ApiService {
2626
}
2727

2828
private handleError(error: HttpErrorResponse, httpMethod: string, url: string) {
29-
if (error.error instanceof ErrorEvent) {
30-
console.error('An error occurred:', error.error.message);
29+
if (httpMethod === 'POST') {
30+
if (error.status >= 500) {
31+
console.error(`POST error ${error.status}: ${error.message}`);
32+
}
33+
} else if (httpMethod === 'GET') {
34+
if (error.status !== 404) {
35+
console.error(`GET error ${error.status}: ${error.message}`);
36+
}
37+
// Else (404 GET error) - do not log
3138
} else {
32-
console.error(
33-
`Backend returned code ${error.status}, url was: ${url} method was: ${httpMethod}, body was: ${JSON.stringify(error.error)}`
34-
);
39+
// For other HTTP methods, you can add custom logic or just log the errors
40+
console.error(`HTTP ${httpMethod} error ${error.status}: ${error.message}`);
3541
}
3642
return throwError(error);
3743
}

0 commit comments

Comments
 (0)