diff --git a/lib/interceptor/response-error.js b/lib/interceptor/response-error.js index 89ac1ee4ee0..70f0c3f67f2 100644 --- a/lib/interceptor/response-error.js +++ b/lib/interceptor/response-error.js @@ -81,8 +81,8 @@ class ResponseErrorHandler extends DecoratorHandler { } } - onResponseError (err) { - super.onResponseError(err) + onResponseError (controller, err) { + super.onResponseError(controller, err) } } diff --git a/test/interceptors/response-error.js b/test/interceptors/response-error.js index b0c0fb63498..996ff546098 100644 --- a/test/interceptors/response-error.js +++ b/test/interceptors/response-error.js @@ -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') +})