Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | 3x 3x 17x 17x 17x 17x 17x 17x 17x | import { getStatusText, INTERNAL_SERVER_ERROR } from 'http-status-codes';
import { FormattedErrorType } from './mongoose-plugin';
export type ApiProblemOptionsType = {
status?: number;
title?: string;
detail?: string | FormattedErrorType[];
instance?: string;
additional?: Record<string, any>;
type?: string;
}
export type SpecErrorType = Omit<ApiProblemOptionsType, 'additional'> & Record<string, any>;
export class ApiProblem extends Error {
status: number;
title?: string;
detail?: string | FormattedErrorType[];
instance?: string;
type?: string;
constructor(props: ApiProblemOptionsType = {}) {
super(props.title || 'Server Error');
this.status = props.status || INTERNAL_SERVER_ERROR;
this.title = props.title || getStatusText(this.status);
this.detail = props.detail;
this.instance = props.instance;
this.type = props?.type;
Object.assign(this, props.additional);
}
} |