UNPKG

@tapsellorg/angular-material-library

Version:

Angular library for Tapsell

33 lines (32 loc) 1.18 kB
import { HttpErrorResponse } from '@angular/common/http'; export type ErrorToastMessageGetter<E extends Record<string, any>> = (error: E, response: HttpErrorResponse) => string; export interface PghErrorDefinitionAction<E extends Record<string, any>> { buttonName: string; afterClick?: (error: E, response: HttpErrorResponse) => void; } export interface PghErrorDefinition<E extends Record<string, any>> { condition: { status?: number; pathEndsWith?: string; response?: Partial<E>; custom?: (error: E, response: HttpErrorResponse) => boolean; }; message?: string | ErrorToastMessageGetter<E>; /** * A callback that is called when this error is matched * @param error * @param response */ callback?: (error: E, response: HttpErrorResponse) => void; isHandled: boolean; action?: PghErrorDefinitionAction<E>; } export interface PghErrorHandler<E extends Record<string, any>> { SERVER_ERRORS: PghErrorDefinition<E>[]; UNHANDLED_ERROR_MESSAGE: string; } export interface PghErrorHandlerResult { isHandled: boolean; message?: string; action?: PghErrorDefinitionAction<any>; }