@t3ned/channel
Version:
Ergonomic, chaining-based Typescript framework for quick API development for Fastify
78 lines • 1.68 kB
TypeScript
import type { HttpStatus } from "../..";
import { ChannelError } from ".";
export declare class ApiError<ErrorData = unknown> extends ChannelError {
/**
* The internal application error code
*/
code?: string | number;
/**
* The error data
*/
data?: ErrorData;
/**
* The error trace
*/
trace?: string;
/**
* The HTTP status code
*/
private _status?;
/**
* The error message
*/
private _message?;
/**
* Set the HTTP status code
* @param status The status
*
* @returns The ApiError
*/
setStatus(status: HttpStatus): this;
/**
* Set the internal application error code
* @param code The code
*
* @returns The ApiError
*/
setCode(code: string | number): this;
/**
* Set the error message
* @param message The message
*
* @returns The ApiError
*/
setMessage(message: string): this;
/**
* Set the error trace
* @param trace The trace
*
* @returns The ApiError
*/
setTrace(trace: string): this;
/**
* Set the error data
* @param data The data
*
* @returns The ApiError
*/
setData(data: ErrorData): this;
/**
* The HTTP status code
*/
get status(): HttpStatus;
/**
* The error message
*/
get message(): string;
/**
* @returns Get the JSON representation of the ApiError
*/
toJSON(): ApiErrorJson<ErrorData>;
}
export interface ApiErrorJson<ErrorData> {
code?: string | number;
message: string;
data?: ErrorData;
trace?: string;
}
//# sourceMappingURL=ApiError.d.ts.map