error-lib
Version:
Standard Error Library for JavaScript/TypeScript projects (NodeJS & Browsers)
25 lines • 1.1 kB
JavaScript
import { NotFoundError, } from './not_found_error';
export class ResourceNotFoundError extends NotFoundError {
/**
*
* @param resourceId Resource identifier
* @param resourceType Resource type
* @param message Error message
* @param opts Extra options
*/
constructor(resourceId, resourceType, message, opts) {
var _a;
// ensure there's always a valid error message
message =
message !== null && message !== void 0 ? message : `ResourceNotFoundError: No ${resourceType} found having identifier '${resourceId}'`;
super(message, {
cause: opts === null || opts === void 0 ? void 0 : opts.cause,
code: (_a = opts === null || opts === void 0 ? void 0 : opts.code) !== null && _a !== void 0 ? _a : 'E_RESOURCE_NOT_FOUND',
});
this.resourceId = resourceId;
this.resourceType = resourceType;
Error.captureStackTrace(this, ResourceNotFoundError);
Object.setPrototypeOf(this, ResourceNotFoundError.prototype);
}
}
//# sourceMappingURL=resource_not_found_error.js.map