@villedemontreal/general-utils
Version:
General utilities library
111 lines • 2.68 kB
TypeScript
import { LogLevel } from './logLevel';
export { LogLevel };
/**
* Represents the final object containing an error to return
* as a response to a request.
*/
export interface IErrorResponse {
/**
* The error object.
*/
error: IApiError;
}
/**
* Error Reponse Type Guard
*/
export declare const isErrorResponse: (obj: any) => obj is IErrorResponse;
/**
* An error object.
*/
export interface IApiError {
/**
* One of a server-defined set of error codes.
*/
code: string;
/**
* A human-readable representation of the error.
*/
message: string;
/**
* The target of the error.
*/
target?: string;
/**
* An array of details about specific errors that led to this reported error.
*/
details?: IApiError[];
/**
* An object containing more specific information than the current object
* about the error.
*/
innererror?: IApiInnerError;
}
/**
* Error Type Guard
*/
export declare const isApiError: (obj: any) => obj is IApiError;
/**
* An object containing more specific information than the current
* object about the error.
*/
export interface IApiInnerError {
/**
* A more specific error code than was provided by the containing error.
*/
code?: string;
/**
* An object containing more specific information than the current object
* about the error.
*/
innererror?: IApiInnerError;
/**
* Any number of custom properties.
*/
[name: string]: any;
}
/**
* Represents an error and some extra informations
* to use to manage it.
*/
export interface IApiErrorAndInfo {
/**
* The error to send.
*/
error: IApiError;
/**
* The http status to use to send the error.
*/
httpStatus: number;
/**
* The log message
*/
logMessage: any;
/**
* The log level
*/
logLevel?: LogLevel;
/**
* Log stackTrace?
*/
logStackTrace?: boolean;
}
/**
* IApiErrorAndInfo Type Guard
*/
export declare const isApiErrorAndInfo: (obj: any) => obj is IApiErrorAndInfo;
/**
* Concrete error class to throw. It contains the actual error
* to return and some extra info to help manage it.
*
* Since it extends the standard Node "Error" class, the stack trace will
* be available.
*/
export declare class ApiErrorAndInfo extends Error implements IApiErrorAndInfo {
error: IApiError;
logMessage: any;
httpStatus: number;
logLevel: LogLevel;
logStackTrace: boolean;
constructor(error: IApiError, logMessage: any, httpStatus: number, logLevel: LogLevel, logStackTrace: boolean);
}
//# sourceMappingURL=apiError.d.ts.map