Skip to content

Commit

Permalink
fix: response error interceptor (#3930)
Browse files Browse the repository at this point in the history
  • Loading branch information
Gigioliva authored Dec 8, 2024
1 parent 03edf68 commit 503ad76
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/interceptor/response-error.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,8 @@ class ResponseErrorHandler extends DecoratorHandler {
}
}

onResponseError (err) {
super.onResponseError(err)
onResponseError (controller, err) {
super.onResponseError(controller, err)
}
}

Expand Down
25 changes: 25 additions & 0 deletions test/interceptors/response-error.js
Original file line number Diff line number Diff line change
Expand Up @@ -168,3 +168,28 @@ test('should throw error for error response, parsing JSON without charset', asyn
message: 'Bad Request'
})
})

test('should throw error for networking errors response', async () => {
const client = new Client(
'http://localhost:12345'
).compose(responseError())

after(async () => {
await client.close()
})

let error
try {
await client.request({
method: 'GET',
path: '/',
headers: {
'content-type': 'text/plain'
}
})
} catch (err) {
error = err
}

assert.equal(error.code, 'ECONNREFUSED')
})

0 comments on commit 503ad76

Please sign in to comment.