rfc9457
Version:
RFC 9457 Problem Details for HTTP APIs - A standardized error handling package for Node.js
27 lines • 736 B
JavaScript
export class HttpError extends Error {
type;
title;
status;
detail;
instance;
constructor(params) {
super(params.detail, { cause: params.cause });
this.name = "HttpError";
this.type = params.type;
this.title = params.title;
this.status = params.status;
this.detail = params.detail;
this.instance = params.instance;
Error.captureStackTrace(this, this.constructor);
}
toJSON() {
return {
type: this.type,
title: this.title,
status: this.status,
detail: this.detail,
...(this.instance && { instance: this.instance }),
};
}
}
//# sourceMappingURL=http-error.js.map