Skip to content

Commit

Permalink
feat: better StatusCodeError.message
Browse files Browse the repository at this point in the history
  • Loading branch information
analog-nico committed Apr 16, 2016
1 parent dcd18ad commit 2ad8792
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/errors.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ function StatusCodeError(statusCode, message) {

this.name = 'StatusCodeError';
this.statusCode = statusCode;
this.message = statusCode + ' - ' + message;
this.message = statusCode + ' - ' + (JSON && JSON.stringify ? JSON.stringify(message) : message);

if (Error.captureStackTrace) { // if required for non-V8 envs - see PR #40
Error.captureStackTrace(this);
Expand Down
2 changes: 1 addition & 1 deletion test/spec/request-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ describe('Request-Promise', function () {
expect(reason instanceof errors.StatusCodeError).to.eql(true);
expect(reason.name).to.eql('StatusCodeError');
expect(reason.statusCode).to.eql(404);
expect(reason.message).to.eql('404 - GET /404');
expect(reason.message).to.eql('404 - "GET /404"');

throw reason; // Testing Bluebird's catch by type
})
Expand Down

0 comments on commit 2ad8792

Please sign in to comment.