* Thrown when a unique constraint is violated in the database
| 17 | * Thrown when a unique constraint is violated in the database |
| 18 | */ |
| 19 | class UniqueConstraintError extends ValidationError implements CommonErrorProperties { |
| 20 | readonly parent: UniqueConstraintErrorParent; |
| 21 | readonly original: UniqueConstraintErrorParent; |
| 22 | readonly fields: Record<string, unknown>; |
| 23 | readonly sql: string; |
| 24 | |
| 25 | constructor(options: UniqueConstraintErrorOptions) { |
| 26 | options = options ?? {}; |
| 27 | options.parent = options.parent ?? { sql: '', name: '', message: '' }; |
| 28 | options.message = |
| 29 | options.message || options.parent.message || 'Validation Error'; |
| 30 | options.errors = options.errors ?? []; |
| 31 | super(options.message, options.errors, { stack: options.stack }); |
| 32 | |
| 33 | this.name = 'SequelizeUniqueConstraintError'; |
| 34 | this.fields = options.fields ?? {}; |
| 35 | this.parent = options.parent; |
| 36 | this.original = options.parent; |
| 37 | this.sql = options.parent.sql; |
| 38 | } |
| 39 | } |
| 40 | |
| 41 | export default UniqueConstraintError; |
nothing calls this directly
no outgoing calls
no test coverage detected