File tree Expand file tree Collapse file tree 2 files changed +10
-1
lines changed Expand file tree Collapse file tree 2 files changed +10
-1
lines changed Original file line number Diff line number Diff line change @@ -66,8 +66,8 @@ function Connection(options = {}) {
66
66
? socket . write ( frontend . Close ( ) )
67
67
: socket . write ( frontend . Execute ( backend . query . cursor . rows ) )
68
68
} ) . catch ( err => {
69
- socket . write ( frontend . Close ( ) )
70
69
backend . query . reject ( err )
70
+ socket . write ( frontend . Close ( ) )
71
71
} )
72
72
}
73
73
@@ -114,6 +114,7 @@ function Connection(options = {}) {
114
114
}
115
115
116
116
function send ( query , { sig, str, args = [ ] } ) {
117
+ try {
117
118
query . str = str
118
119
query . args = args
119
120
query . result = [ ]
@@ -134,6 +135,9 @@ function Connection(options = {}) {
134
135
open
135
136
? socket . write ( buffer )
136
137
: ( messages . push ( buffer ) , connect ( ) )
138
+ } catch ( err ) {
139
+ query . reject ( err )
140
+ }
137
141
}
138
142
139
143
function connect ( ) {
Original file line number Diff line number Diff line change @@ -1084,3 +1084,8 @@ o('Catches connection config errors', async() => {
1084
1084
await sql `select 1` . catch ( ( e ) => e . message )
1085
1085
]
1086
1086
} )
1087
+
1088
+ o ( 'Catches query format errors' , async ( ) => [
1089
+ 'wat' ,
1090
+ await sql . unsafe ( { toString : ( ) => { throw new Error ( 'wat' ) } } ) . catch ( ( e ) => e . message )
1091
+ ] )
You can’t perform that action at this time.
0 commit comments