UNPKG

@clickup/ent-framework

Version:

A PostgreSQL graph-database-alike library with microsharding and row-level security

38 lines 1.16 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.EntUniqueKeyError = void 0; const misc_1 = require("../../internal/misc"); /** * Error: while inserting or updating, DB unique key was violated, * so the Ent was not mutated. */ class EntUniqueKeyError extends Error { constructor(entName, input) { super(`${entName} mutation violates unique key constraint: ` + (0, misc_1.inspectCompact)(input)); this.entName = entName; this.input = input; Object.defineProperty(this, "name", { value: this.constructor.name, writable: true, enumerable: false, }); } /** * Returns a promise of T on success, and undefined in case unique key * violation happened during the promise resolution. */ static async ignore(promise) { try { return await promise; } catch (e) { if (!(e instanceof this)) { throw e; } return undefined; } } } exports.EntUniqueKeyError = EntUniqueKeyError; //# sourceMappingURL=EntUniqueKeyError.js.map