Skip to content

Commit

Permalink
Add url to errors (#286)
Browse files Browse the repository at this point in the history
  • Loading branch information
alextes authored and sindresorhus committed Mar 24, 2017
1 parent a5f2730 commit a287f8e
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
});
}

Expand Down
2 changes: 1 addition & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
1 change: 1 addition & 0 deletions test/error.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
});

Expand Down

0 comments on commit a287f8e

Please sign in to comment.