UNPKG

@athenna/database

Version:

The Athenna database handler for SQL/NoSQL.

25 lines (24 loc) 978 B
/** * @athenna/database * * (c) João Lenon <lenon@athenna.io> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ import { ConstraintViolationException } from '#src/exceptions/ConstraintViolationException'; export class CheckViolationException extends ConstraintViolationException { constructor(meta = {}) { const { table, constraint, driver, raw } = meta; super({ status: 422, code: 'E_CHECK_VIOLATION', message: `Check constraint${constraint ? ` "${constraint}"` : ''} violated${table ? ` on table "${table}"` : ''}.`, help: `The persisted value does not satisfy the check constraint ${constraint ? `"${constraint}"` : ''}. Provide a value that respects the constraint definition.` }); this.table = table; this.constraint = constraint; this.driver = driver; this.raw = raw; } }