rfc9457
Version:
RFC 9457 Problem Details for HTTP APIs - A standardized error handling package for Node.js
22 lines • 758 B
JavaScript
import { HttpError } from "../../core/index.js";
import { extractCause, getErrorType, normalizeToString, } from "../../helpers/index.js";
export class NotFoundError extends HttpError {
constructor(resourceOrDetail, id) {
let detail;
if (id !== undefined) {
detail = `${String(resourceOrDetail)} ${id} not found`;
}
else {
detail = normalizeToString(resourceOrDetail);
}
super({
type: getErrorType("not-found"),
title: "Not Found",
status: 404,
detail,
cause: id === undefined ? extractCause(resourceOrDetail) : undefined,
});
this.name = "NotFoundError";
}
}
//# sourceMappingURL=not-found-error.js.map