Error interceptor
This commit is contained in:
parent
19915eeff3
commit
3e12f4bfa7
@ -37,6 +37,7 @@ import { PruningTranslationLoader } from '@utils/pruning-translation-loader';
|
||||
import { DatePipe } from '@shared/pipes/date.pipe';
|
||||
import * as links from '../assets/help-mode/links.json';
|
||||
import { HELP_DOCS, IqserHelpModeModule } from '@iqser/common-ui';
|
||||
import { ServerErrorInterceptor } from '@utils/server-error-interceptor';
|
||||
|
||||
export function httpLoaderFactory(httpClient: HttpClient) {
|
||||
return new PruningTranslationLoader(httpClient, '/assets/i18n/', '.json');
|
||||
@ -96,6 +97,11 @@ const components = [
|
||||
ServiceWorkerModule.register('ngsw-worker.js', { enabled: environment.production })
|
||||
],
|
||||
providers: [
|
||||
{
|
||||
provide: HTTP_INTERCEPTORS,
|
||||
multi: true,
|
||||
useClass: ServerErrorInterceptor
|
||||
},
|
||||
{
|
||||
provide: ErrorHandler,
|
||||
useClass: GlobalErrorHandler
|
||||
|
||||
@ -3,7 +3,7 @@ import { AppStateService } from '@state/app-state.service';
|
||||
import { Colors, DictionaryControllerService } from '@redaction/red-ui-http';
|
||||
import { ActivatedRoute } from '@angular/router';
|
||||
import { AdminDialogService } from '../../services/admin-dialog.service';
|
||||
import { CircleButtonTypes, DefaultListingServices, ListingComponent, LoadingService, TableColumnConfig } from '@iqser/common-ui';
|
||||
import { CircleButtonTypes, DefaultListingServices, Listable, ListingComponent, LoadingService, TableColumnConfig } from '@iqser/common-ui';
|
||||
import { DefaultColorType } from '@models/default-color-key.model';
|
||||
import { defaultColorsTranslations } from '../../translations/default-colors-translations';
|
||||
import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker';
|
||||
|
||||
@ -1,9 +1,8 @@
|
||||
import { Component, OnDestroy } from '@angular/core';
|
||||
import { DigitalSignature, DigitalSignatureControllerService } from '@redaction/red-ui-http';
|
||||
import { FormBuilder, FormGroup, Validators } from '@angular/forms';
|
||||
import { AutoUnsubscribe, IconButtonTypes, Toaster } from '@iqser/common-ui';
|
||||
import { lastIndexOfEnd } from '@utils/functions';
|
||||
import { AutoUnsubscribe, IconButtonTypes, LoadingService } from '@iqser/common-ui';
|
||||
import { AutoUnsubscribe, IconButtonTypes, LoadingService, Toaster } from '@iqser/common-ui';
|
||||
import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker';
|
||||
import { UserService } from '@services/user.service';
|
||||
import { RouterHistoryService } from '@services/router-history.service';
|
||||
|
||||
@ -10,15 +10,6 @@ import {
|
||||
TemplateRef,
|
||||
ViewChild
|
||||
} from '@angular/core';
|
||||
import {
|
||||
CircleButtonTypes,
|
||||
DefaultListingServices,
|
||||
keyChecker,
|
||||
ListingComponent,
|
||||
NestedFilter,
|
||||
TableColumnConfig,
|
||||
Toaster
|
||||
} from '@iqser/common-ui';
|
||||
import { AppStateService } from '@state/app-state.service';
|
||||
import { FileDropOverlayService } from '@upload-download/services/file-drop-overlay.service';
|
||||
import { FileUploadModel } from '@upload-download/model/file-upload.model';
|
||||
@ -45,7 +36,8 @@ import {
|
||||
ListingComponent,
|
||||
LoadingService,
|
||||
NestedFilter,
|
||||
TableColumnConfig
|
||||
TableColumnConfig,
|
||||
Toaster
|
||||
} from '@iqser/common-ui';
|
||||
import { DossierAttributesService } from '@shared/services/controller-wrappers/dossier-attributes.service';
|
||||
import { DossierAttributeWithValue } from '@models/dossier-attributes.model';
|
||||
|
||||
20
apps/red-ui/src/app/utils/server-error-interceptor.ts
Normal file
20
apps/red-ui/src/app/utils/server-error-interceptor.ts
Normal file
@ -0,0 +1,20 @@
|
||||
import { HttpErrorResponse, HttpEvent, HttpHandler, HttpInterceptor, HttpRequest } from '@angular/common/http';
|
||||
import { Injectable } from '@angular/core';
|
||||
import { ErrorService } from '@iqser/common-ui';
|
||||
import { Observable, throwError } from 'rxjs';
|
||||
import { catchError, map } from 'rxjs/operators';
|
||||
|
||||
@Injectable()
|
||||
export class ServerErrorInterceptor implements HttpInterceptor {
|
||||
constructor(private readonly _errorService: ErrorService) {}
|
||||
|
||||
intercept(req: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> {
|
||||
return next.handle(req).pipe(
|
||||
map((event: HttpEvent<any>) => event),
|
||||
catchError((error: HttpErrorResponse) => {
|
||||
if ([0, 500].includes(error.status)) this._errorService.set(error);
|
||||
return throwError(error);
|
||||
})
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -1 +1 @@
|
||||
Subproject commit 69135886ab3cfb65843e87e2407c40fc30960f1f
|
||||
Subproject commit 82f27f1ed9ff98c98877c4cf128b4b41832a1724
|
||||
Loading…
x
Reference in New Issue
Block a user