typeorm
Version:
Data-Mapper ORM for TypeScript, ES7, ES6, ES5. Supports MySQL, PostgreSQL, MariaDB, SQLite, MS SQL Server, Oracle, MongoDB databases.
41 lines (39 loc) • 1.49 kB
JavaScript
import { __extends } from "tslib";
import { EntitySchema } from "../index";
/**
* Thrown when no result could be found in methods which are not allowed to return undefined or an empty set.
*/
var EntityNotFoundError = /** @class */ (function (_super) {
__extends(EntityNotFoundError, _super);
function EntityNotFoundError(entityClass, criteria) {
var _this = _super.call(this) || this;
_this.name = "EntityNotFound";
Object.setPrototypeOf(_this, EntityNotFoundError.prototype);
var targetName;
if (entityClass instanceof EntitySchema) {
targetName = entityClass.options.name;
}
else if (typeof entityClass === "function") {
targetName = entityClass.name;
}
else if (typeof entityClass === "object" && "name" in entityClass) {
targetName = entityClass.name;
}
else {
targetName = entityClass;
}
var criteriaString = _this.stringifyCriteria(criteria);
_this.message = "Could not find any entity of type \"" + targetName + "\" matching: " + criteriaString;
return _this;
}
EntityNotFoundError.prototype.stringifyCriteria = function (criteria) {
try {
return JSON.stringify(criteria, null, 4);
}
catch (e) { }
return "" + criteria;
};
return EntityNotFoundError;
}(Error));
export { EntityNotFoundError };
//# sourceMappingURL=EntityNotFoundError.js.map