forked from typeorm/typeorm
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathQueryFailedError.ts
More file actions
32 lines (29 loc) · 833 Bytes
/
QueryFailedError.ts
File metadata and controls
32 lines (29 loc) · 833 Bytes
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
import { ObjectUtils } from "../util/ObjectUtils"
import { TypeORMError } from "./TypeORMError"
/**
* Thrown when query execution has failed.
*/
export class QueryFailedError<T extends Error = Error> extends TypeORMError {
constructor(
readonly query: string,
readonly parameters: any[] | undefined,
readonly driverError: T,
) {
super(
driverError
.toString()
.replace(/^error: /, "")
.replace(/^Error: /, "")
.replace(/^Request/, ""),
)
if (driverError) {
const {
name: _, // eslint-disable-line
...otherProperties
} = driverError
ObjectUtils.assign(this, {
...otherProperties,
})
}
}
}