UNPKG

1.27 kBJavaScriptView Raw
1"use strict";
2// Copyright IBM Corp. and LoopBack contributors 2018,2019. All Rights Reserved.
3// Node module: @loopback/repository
4// This file is licensed under the MIT License.
5// License text available at https://opensource.org/licenses/MIT
6Object.defineProperty(exports, "__esModule", { value: true });
7exports.isEntityNotFoundError = exports.EntityNotFoundError = void 0;
8class EntityNotFoundError extends Error {
9 constructor(entityOrName, entityId, extraProperties) {
10 const entityName = typeof entityOrName === 'string'
11 ? entityOrName
12 : entityOrName.modelName || entityOrName.name;
13 const quotedId = JSON.stringify(entityId);
14 super(`Entity not found: ${entityName} with id ${quotedId}`);
15 Error.captureStackTrace(this, this.constructor);
16 this.code = 'ENTITY_NOT_FOUND';
17 this.entityName = entityName;
18 this.entityId = entityId;
19 Object.assign(this, extraProperties);
20 }
21}
22exports.EntityNotFoundError = EntityNotFoundError;
23// eslint-disable-next-line @typescript-eslint/no-explicit-any
24function isEntityNotFoundError(e) {
25 return e instanceof EntityNotFoundError;
26}
27exports.isEntityNotFoundError = isEntityNotFoundError;
28//# sourceMappingURL=entity-not-found.error.js.map
\No newline at end of file