UNPKG

@versatiledatakit/shared

Version:

Versatile Data Kit Shared library enables reusability of shared features like: NgRx Redux, Error Handlers, Utils, Generic Components, etc.

54 lines (53 loc) 1.45 kB
import { Observable } from 'rxjs'; import { Toast } from '../../toasts/model'; import { ToastService } from '../../toasts/service'; import * as i0 from "@angular/core"; /** * ** Config for Toast message. */ export interface ErrorHandlerConfig { /** * ** Toast title. */ title?: Toast['title']; /** * ** Toast description. */ description?: Toast['description']; /** * ** Toast type. */ type?: Toast['type']; } /** * ** Error handler service. */ export declare class ErrorHandlerService { private readonly toastService; /** * ** Constructor. */ constructor(toastService: ToastService); /** * ** Handle Error in rxjs stream. * * - Show Toast message * - Log it to console * - Re-throw new Error('Something unexpected happened') */ handleError: (error: Error) => Observable<never>; /** * ** Process Error. * * - Show Toast message * - Log it to console */ processError(error: Error): void; processError(error: Error, overriddenConfig: ErrorHandlerConfig): void; private static _createToastConfigForHttpErrorResponse; private static _createToastConfigForError; private static _getErrorTitle; private static _createToastConfig; static ɵfac: i0.ɵɵFactoryDeclaration<ErrorHandlerService, never>; static ɵprov: i0.ɵɵInjectableDeclaration<ErrorHandlerService>; }