Browse Source

Add url to errors (#286)

extract-response
Alexander Tesfamichael 8 years ago
committed by Sindre Sorhus
parent
commit
a287f8ec8a
  1. 3
      index.js
  2. 2
      readme.md
  3. 1
      test/error.js

3
index.js

@ -336,7 +336,8 @@ function stdError(error, opts) {
hostname: opts.hostname,
method: opts.method,
path: opts.path,
protocol: opts.protocol
protocol: opts.protocol,
url: opts.href
});
}

2
readme.md

@ -176,7 +176,7 @@ Sets `options.method` to the method name and makes a request.
## Errors
Each error contains (if available) `statusCode`, `statusMessage`, `host`, `hostname`, `method` and `path` properties to make debugging easier.
Each error contains (if available) `statusCode`, `statusMessage`, `host`, `hostname`, `method`, `path`, `protocol` and `url` properties to make debugging easier.
In Promise mode, the `response` is attached to the error.

1
test/error.js

@ -28,6 +28,7 @@ test('properties', async t => {
t.is(err.host, `${s.host}:${s.port}`);
t.is(err.method, 'GET');
t.is(err.protocol, 'http:');
t.is(err.url, err.response.requestUrl);
}
});

Loading…
Cancel
Save