@@ -111,7 +111,7 @@ class Protocol {
111
111
this . writeBuf . endRequest ( ) ;
112
112
}
113
113
114
- async _recoverFromError ( message ) {
114
+ async _recoverFromError ( caughtErr , message ) {
115
115
/*
116
116
* We have NJS error(protocol related) detected during packet write/read
117
117
* operation. Issue a break and reset to clear channel . We receive the
@@ -124,10 +124,12 @@ class Protocol {
124
124
await this . readBuf . waitForPackets ( ) ;
125
125
message . decode ( this . readBuf ) ;
126
126
} catch ( err ) { // Recovery failed
127
- // TODO: throw different error indicating that reset failed, probably
128
- // put inside resetMessage()
129
127
this . nsi . disconnect ( ) ;
130
- errors . throwErr ( errors . ERR_CONNECTION_CLOSED ) ;
128
+ const newErr = errors . getErr ( errors . ERR_CONNECTION_CLOSED ) ;
129
+ caughtErr . message = newErr . message +
130
+ "\nError recovery failed: " + err . message +
131
+ "\nOriginal error: " + caughtErr . message ;
132
+ throw caughtErr ;
131
133
}
132
134
}
133
135
@@ -153,7 +155,7 @@ class Protocol {
153
155
} catch ( err ) {
154
156
if ( ! this . connInProgress &&
155
157
err . code !== errors . ERR_CONNECTION_CLOSED_CODE ) {
156
- await this . _recoverFromError ( message ) ;
158
+ await this . _recoverFromError ( err , message ) ;
157
159
}
158
160
throw err ;
159
161
} finally {
0 commit comments