errors.d.ts
4.98 KB
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
/**
* The Base Error all Sequelize Errors inherit from.
*/
export class BaseError extends Error {
public name: string;
}
/**
* Scope Error. Thrown when the sequelize cannot query the specified scope.
*/
export class SequelizeScopeError extends BaseError {}
export class ValidationError extends BaseError {
/** Array of ValidationErrorItem objects describing the validation errors */
public readonly errors: ValidationErrorItem[];
/**
* Validation Error. Thrown when the sequelize validation has failed. The error contains an `errors`
* property, which is an array with 1 or more ValidationErrorItems, one for each validation that failed.
*
* @param message Error message
* @param errors Array of ValidationErrorItem objects describing the validation errors
*/
constructor(message: string, errors?: ValidationErrorItem[]);
/**
* Gets all validation error items for the path / field specified.
*
* @param path The path to be checked for error items
*/
public get(path: string): ValidationErrorItem[];
}
export class ValidationErrorItem {
/** An error message */
public readonly message: string;
/** The type of the validation error */
public readonly type: string;
/** The field that triggered the validation error */
public readonly path: string;
/** The value that generated the error */
public readonly value: string;
public readonly original: Error;
/**
* Validation Error Item
* Instances of this class are included in the `ValidationError.errors` property.
*
* @param message An error message
* @param type The type of the validation error
* @param path The field that triggered the validation error
* @param value The value that generated the error
*/
constructor(message?: string, type?: string, path?: string, value?: string);
}
export interface CommonErrorProperties {
/** The database specific error which triggered this one */
readonly parent: Error;
/** The database specific error which triggered this one */
readonly original: Error;
/** The SQL that triggered the error */
readonly sql: string;
}
/**
* Thrown when a record was not found, Usually used with rejectOnEmpty mode (see message for details)
*/
export class EmptyResultError extends BaseError {
}
export class DatabaseError extends BaseError implements CommonErrorProperties {
public readonly parent: Error;
public readonly original: Error;
public readonly sql: string;
/**
* A base class for all database related errors.
* @param parent The database specific error which triggered this one
*/
constructor(parent: Error);
}
/** Thrown when a database query times out because of a deadlock */
export class TimeoutError extends DatabaseError {}
export interface UniqueConstraintErrorOptions {
parent?: Error;
message?: string;
errors?: ValidationErrorItem[];
fields?: { [key: string]: any };
original?: Error;
}
/**
* Thrown when a unique constraint is violated in the database
*/
export class UniqueConstraintError extends ValidationError implements CommonErrorProperties {
public readonly parent: Error;
public readonly original: Error;
public readonly sql: string;
public readonly fields: { [key: string]: any };
constructor(options?: UniqueConstraintErrorOptions);
}
/**
* Thrown when a foreign key constraint is violated in the database
*/
export class ForeignKeyConstraintError extends DatabaseError {
public table: string;
public fields: { [field: string]: string };
public value: any;
public index: string;
constructor(options: { parent?: Error; message?: string; index?: string; fields?: string[]; table?: string });
}
/**
* Thrown when an exclusion constraint is violated in the database
*/
export class ExclusionConstraintError extends DatabaseError {
public constraint: string;
public fields: { [field: string]: string };
public table: string;
constructor(options: { parent?: Error; message?: string; constraint?: string; fields?: string[]; table?: string });
}
/**
* A base class for all connection related errors.
*/
export class ConnectionError extends BaseError {
public parent: Error;
public original: Error;
constructor(parent: Error);
}
/**
* Thrown when a connection to a database is refused
*/
export class ConnectionRefusedError extends ConnectionError {}
/**
* Thrown when a connection to a database is refused due to insufficient privileges
*/
export class AccessDeniedError extends ConnectionError {}
/**
* Thrown when a connection to a database has a hostname that was not found
*/
export class HostNotFoundError extends ConnectionError {}
/**
* Thrown when a connection to a database has a hostname that was not reachable
*/
export class HostNotReachableError extends ConnectionError {}
/**
* Thrown when a connection to a database has invalid values for any of the connection parameters
*/
export class InvalidConnectionError extends ConnectionError {}
/**
* Thrown when a connection to a database times out
*/
export class ConnectionTimedOutError extends ConnectionError {}