File tree Expand file tree Collapse file tree 3 files changed +12
-1
lines changed Expand file tree Collapse file tree 3 files changed +12
-1
lines changed Original file line number Diff line number Diff line change @@ -13,7 +13,7 @@ class SqlError extends Error {
13
13
( sql ? '\nsql: ' + sql : '' )
14
14
) ;
15
15
this . name = 'SqlError' ;
16
- this . text = msg ;
16
+ this . sqlMessage = msg ;
17
17
this . sql = sql ;
18
18
this . fatal = fatal ;
19
19
this . errno = errno ;
@@ -29,6 +29,10 @@ class SqlError extends Error {
29
29
this . stack += '\n From event:\n' + additionalStack . substring ( additionalStack . indexOf ( '\n' ) + 1 ) ;
30
30
}
31
31
}
32
+
33
+ get text ( ) {
34
+ return this . sqlMessage ;
35
+ }
32
36
}
33
37
34
38
/**
Original file line number Diff line number Diff line change @@ -41,6 +41,7 @@ describe('Error', () => {
41
41
assert . equal ( err . sqlState , 42000 ) ;
42
42
assert . isTrue ( err . message . includes ( 'You have an error in your SQL syntax' ) ) ;
43
43
assert . isTrue ( err . message . includes ( 'sql: wrong query - parameters:[]' ) ) ;
44
+ assert . isTrue ( err . sqlMessage . includes ( 'You have an error in your SQL syntax' ) ) ;
44
45
}
45
46
}
46
47
conn . end ( ) ;
Original file line number Diff line number Diff line change @@ -852,9 +852,15 @@ export interface SqlError extends Error {
852
852
853
853
/**
854
854
* original error message value
855
+ * @deprecated since 3.2.0 prefer using sqlMessage for compatibility with other drivers.
855
856
*/
856
857
text : string | null ;
857
858
859
+ /**
860
+ * original error message value
861
+ */
862
+ sqlMessage : string | null ;
863
+
858
864
/**
859
865
* The sql command associate
860
866
*/
You can’t perform that action at this time.
0 commit comments