Commit 2ad87923 authored by analog-nico's avatar analog-nico
Browse files

feat: better StatusCodeError.message

parent dcd18ad8
Loading
Loading
Loading
Loading
+1 −1
Original line number Original line Diff line number Diff line
@@ -20,7 +20,7 @@ function StatusCodeError(statusCode, message) {


    this.name = 'StatusCodeError';
    this.name = 'StatusCodeError';
    this.statusCode = statusCode;
    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
    if (Error.captureStackTrace) { // if required for non-V8 envs - see PR #40
        Error.captureStackTrace(this);
        Error.captureStackTrace(this);
+1 −1
Original line number Original line Diff line number Diff line
@@ -172,7 +172,7 @@ describe('Request-Promise', function () {
                    expect(reason instanceof errors.StatusCodeError).to.eql(true);
                    expect(reason instanceof errors.StatusCodeError).to.eql(true);
                    expect(reason.name).to.eql('StatusCodeError');
                    expect(reason.name).to.eql('StatusCodeError');
                    expect(reason.statusCode).to.eql(404);
                    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
                    throw reason; // Testing Bluebird's catch by type
                })
                })