-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
/
unknown-constraint-error.ts
33 lines (27 loc) · 1.01 KB
/
unknown-constraint-error.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import DatabaseError, { DatabaseErrorSubclassOptions } from '../database-error';
interface UnknownConstraintErrorOptions {
constraint?: string;
fields?: Record<string, string | number>;
table?: string;
}
/**
* Thrown when constraint name is not found in the database
*/
class UnknownConstraintError extends DatabaseError implements UnknownConstraintErrorOptions {
constraint: string | undefined;
fields: Record<string, string | number> | undefined;
table: string | undefined;
constructor(
options: UnknownConstraintErrorOptions & DatabaseErrorSubclassOptions
) {
options = options || {};
options.parent = options.parent || { sql: '', name: '', message: '' };
super(options.parent, { stack: options.stack });
this.name = 'SequelizeUnknownConstraintError';
this.message = options.message || 'The specified constraint does not exist';
this.constraint = options.constraint;
this.fields = options.fields;
this.table = options.table;
}
}
export default UnknownConstraintError;