UNPKG

1.6 kBTypeScriptView Raw
1/**
2 * @author: Prachi Singh (prachi@hackcapital.com)
3 * @date: Monday, 6th May 2019 11:11:49 am
4 * @lastModifiedBy: Prachi Singh (prachi@hackcapital.com)
5 * @lastModifiedTime: Thursday, 3rd October 2019 4:46:05 pm
6 *
7 * DESCRIPTION: Base class that the custom errors should be extending from
8 * Error template that provides a modular, extensible and customizable errors.
9 * Sourced from https://git.cto.ai/hackcapital/tools/errors
10 * Modified slightly to fit the application's need
11 *
12 * @copyright (c) 2019 Hack Capital
13 */
14import { IExtra } from '../types';
15/**
16 * ErrorTemplate class provide a base class for customized errors
17 *
18 * @extends Error
19 */
20export declare class ErrorTemplate extends Error {
21 message: string;
22 original?: Error | ErrorResponse | undefined;
23 statusCode?: number | undefined;
24 errorCode?: string | undefined;
25 extra: IExtra;
26 /**
27 * @constructor
28 *
29 * @param {String} [message] Error Message
30 * @param {Object} [extra] Append any extra information to the error message
31 * @param {Number} [statusCode] Specific for HTTP request, e.g.: 404
32 * @param {String} [errorCode] Error codes, e.g.: U0010
33 * @param {Error} [original] Original error object
34 */
35 constructor(message: string, original?: Error | ErrorResponse | undefined, extra?: IExtra, statusCode?: number | undefined, errorCode?: string | undefined);
36}
37export interface ErrorResponse {
38 data: null;
39 error: GoError[];
40 message: string;
41 stack: string;
42}
43export interface GoError {
44 requestID: string;
45 code: number;
46 message: string;
47}