1 | 'use strict';
|
2 |
|
3 | const ValidationError = require('./../validation-error');
|
4 |
|
5 |
|
6 |
|
7 |
|
8 | class UniqueConstraintError extends ValidationError {
|
9 | constructor(options) {
|
10 | options = options || {};
|
11 | options.parent = options.parent || { sql: '' };
|
12 | options.message = options.message || options.parent.message || 'Validation Error';
|
13 | options.errors = options.errors || {};
|
14 | super(options.message, options.errors);
|
15 |
|
16 | this.name = 'SequelizeUniqueConstraintError';
|
17 | this.errors = options.errors;
|
18 | this.fields = options.fields;
|
19 | this.parent = options.parent;
|
20 | this.original = options.parent;
|
21 | this.sql = options.parent.sql;
|
22 | Error.captureStackTrace(this, this.constructor);
|
23 | }
|
24 | }
|
25 |
|
26 | module.exports = UniqueConstraintError;
|