UNPKG

@othree.io/excuses

Version:

Excuses

28 lines 1.11 kB
/** * Custom Error class representing a not found error. */ export class NotFoundError extends Error { /** Static error code to identify the error type. */ static ERROR = 'NotFoundError'; /** Identifier associated with the not-found resource. */ id; /** * 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`; } } } //# sourceMappingURL=not-found-error.js.map