1 |
|
2 |
|
3 |
|
4 | export class BaseError extends Error {
|
5 | public name: string;
|
6 | }
|
7 |
|
8 |
|
9 |
|
10 |
|
11 | export class SequelizeScopeError extends BaseError {}
|
12 |
|
13 | export class ValidationError extends BaseError {
|
14 |
|
15 | public readonly errors: ValidationErrorItem[];
|
16 |
|
17 | |
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 |
|
24 | constructor(message: string, errors?: ValidationErrorItem[]);
|
25 |
|
26 | /**
|
27 | * Gets all validation error items for the path / field specified.
|
28 | *
|
29 | * @param path The path to be checked for error items
|
30 | */
|
31 | public get(path: string): ValidationErrorItem[];
|
32 | }
|
33 |
|
34 | export class ValidationErrorItem {
|
35 |
|
36 | public readonly message: string;
|
37 |
|
38 |
|
39 | public readonly type: string;
|
40 |
|
41 |
|
42 | public readonly path: string;
|
43 |
|
44 |
|
45 | public readonly value: string;
|
46 |
|
47 | public readonly original: Error;
|
48 |
|
49 | |
50 |
|
51 |
|
52 |
|
53 |
|
54 |
|
55 |
|
56 |
|
57 |
|
58 | constructor(message?: string, type?: string, path?: string, value?: string);
|
59 | }
|
60 |
|
61 | export interface CommonErrorProperties {
|
62 |
|
63 | readonly parent: Error;
|
64 |
|
65 |
|
66 | readonly original: Error;
|
67 |
|
68 |
|
69 | readonly sql: string;
|
70 | }
|
71 |
|
72 |
|
73 |
|
74 |
|
75 | export class EmptyResultError extends BaseError {
|
76 | }
|
77 |
|
78 | export class DatabaseError extends BaseError implements CommonErrorProperties {
|
79 | public readonly parent: Error;
|
80 | public readonly original: Error;
|
81 | public readonly sql: string;
|
82 | public readonly parameters: Array<any>;
|
83 | |
84 |
|
85 |
|
86 |
|
87 | constructor(parent: Error);
|
88 | }
|
89 |
|
90 | /** Thrown when a database query times out because of a deadlock */
|
91 | export class TimeoutError extends DatabaseError {}
|
92 |
|
93 | export interface UniqueConstraintErrorOptions {
|
94 | parent?: Error;
|
95 | message?: string;
|
96 | errors?: ValidationErrorItem[];
|
97 | fields?: { [key: string]: unknown };
|
98 | original?: Error;
|
99 | }
|
100 |
|
101 |
|
102 |
|
103 |
|
104 | export class UniqueConstraintError extends ValidationError implements CommonErrorProperties {
|
105 | public readonly parent: Error;
|
106 | public readonly original: Error;
|
107 | public readonly sql: string;
|
108 | public readonly fields: { [key: string]: unknown };
|
109 | constructor(options?: UniqueConstraintErrorOptions);
|
110 | }
|
111 |
|
112 | /**
|
113 | * Thrown when a foreign key constraint is violated in the database
|
114 | */
|
115 | export class ForeignKeyConstraintError extends DatabaseError {
|
116 | public table: string;
|
117 | public fields: { [field: string]: string };
|
118 | public value: unknown;
|
119 | public index: string;
|
120 | constructor(options: { parent?: Error; message?: string; index?: string; fields?: string[]; table?: string });
|
121 | }
|
122 |
|
123 | /**
|
124 | * Thrown when an exclusion constraint is violated in the database
|
125 | */
|
126 | export class ExclusionConstraintError extends DatabaseError {
|
127 | public constraint: string;
|
128 | public fields: { [field: string]: string };
|
129 | public table: string;
|
130 | constructor(options: { parent?: Error; message?: string; constraint?: string; fields?: string[]; table?: string });
|
131 | }
|
132 |
|
133 | /**
|
134 | * Thrown when attempting to update a stale model instance
|
135 | */
|
136 | export class OptimisticLockError extends BaseError {
|
137 | constructor(options: { message?: string, modelName?: string, values?: { [key: string]: any }, where?: { [key: string]: any } });
|
138 | }
|
139 |
|
140 | /**
|
141 | * A base class for all connection related errors.
|
142 | */
|
143 | export class ConnectionError extends BaseError {
|
144 | public parent: Error;
|
145 | public original: Error;
|
146 | constructor(parent: Error);
|
147 | }
|
148 |
|
149 | /**
|
150 | * Thrown when a connection to a database is refused
|
151 | */
|
152 | export class ConnectionRefusedError extends ConnectionError {}
|
153 |
|
154 |
|
155 |
|
156 |
|
157 | export class AccessDeniedError extends ConnectionError {}
|
158 |
|
159 |
|
160 |
|
161 |
|
162 | export class HostNotFoundError extends ConnectionError {}
|
163 |
|
164 |
|
165 |
|
166 |
|
167 | export class HostNotReachableError extends ConnectionError {}
|
168 |
|
169 |
|
170 |
|
171 |
|
172 | export class InvalidConnectionError extends ConnectionError {}
|
173 |
|
174 |
|
175 |
|
176 |
|
177 | export class ConnectionTimedOutError extends ConnectionError {}
|