@othree.io/excuses
Version:
Excuses
30 lines • 1.18 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.NotFoundError = void 0;
/**
* Custom Error class representing a not found error.
*/
class NotFoundError extends Error {
/**
* Creates a new NotFoundError.
*
* @param {string} [id] - Identifier associated with the not-found resource.
* @param {string} [type] - Type or category of the resource that was not found.
* @param {string} [message] - Optional custom error message.
*/
constructor(id, type, message) {
super(message);
// https://github.com/Microsoft/TypeScript-wiki/blob/main/Breaking-Changes.md#extending-built-ins-like-error-array-and-map-may-no-longer-work
Object.setPrototypeOf(this, new.target.prototype); // restore prototype chain
this.name = NotFoundError.ERROR;
this.id = id;
this.stack = new Error().stack;
if (id && type) {
this.message = `${type} with id: ${id} was not found`;
}
}
}
exports.NotFoundError = NotFoundError;
/** Static error code to identify the error type. */
NotFoundError.ERROR = 'NotFoundError';
//# sourceMappingURL=not-found-error.js.map