Skip to content

Commit

Permalink
PR Comments
Browse files Browse the repository at this point in the history
  • Loading branch information
anishfyle committed May 22, 2024
1 parent 3a0158d commit 9b9742b
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 63 deletions.
6 changes: 0 additions & 6 deletions src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import { SharedModule } from './shared/shared.module';
import { RippleModule } from 'primeng/ripple';
import { BrandingService } from './core/services/common/branding.service';
import { Sage300ConfigurationModule } from './integrations/sage300/sage300-main/sage300-configuration/sage300-configuration.module';
import { HttpErrorInterceptor } from './core/interceptor/http-error.interceptor';

@NgModule({
declarations: [
Expand Down Expand Up @@ -47,11 +46,6 @@ import { HttpErrorInterceptor } from './core/interceptor/http-error.interceptor'
useClass: JwtInterceptor,
multi: true
},
{
provide: HTTP_INTERCEPTORS,
useClass: HttpErrorInterceptor,
multi: true
},
{
provide: ErrorHandler,
useClass: GlobalErrorHandler
Expand Down
16 changes: 0 additions & 16 deletions src/app/core/interceptor/http-error.interceptor.spec.ts

This file was deleted.

36 changes: 0 additions & 36 deletions src/app/core/interceptor/http-error.interceptor.ts

This file was deleted.

16 changes: 11 additions & 5 deletions src/app/core/services/common/api.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,18 @@ export class ApiService {
}

private handleError(error: HttpErrorResponse, httpMethod: string, url: string) {
if (error.error instanceof ErrorEvent) {
console.error('An error occurred:', error.error.message);
if (httpMethod === 'POST') {
if (error.status >= 500) {
console.error(`POST error ${error.status}: ${error.message}`);
}
} else if (httpMethod === 'GET') {
if (error.status !== 404) {
console.error(`GET error ${error.status}: ${error.message}`);
}
// Else (404 GET error) - do not log
} else {
console.error(
`Backend returned code ${error.status}, url was: ${url} method was: ${httpMethod}, body was: ${JSON.stringify(error.error)}`
);
// For other HTTP methods, you can add custom logic or just log the errors
console.error(`HTTP ${httpMethod} error ${error.status}: ${error.message}`);
}
return throwError(error);
}
Expand Down

0 comments on commit 9b9742b

Please sign in to comment.