Skip to content

Commit

Permalink
Merge pull request #40 from nodiis/master
Browse files Browse the repository at this point in the history
Improved Error types to work in browsers without v8 engine
  • Loading branch information
analog-nico committed Mar 19, 2015
2 parents 0212b0b + 5dc0bce commit 1d11365
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions lib/errors.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@ function RequestError(cause) {
this.message = String(cause);
this.cause = cause;

Error.captureStackTrace(this);
if(Error.captureStackTrace){
Error.captureStackTrace(this);
} else {
Error.call(this);
}

}
RequestError.prototype = Object.create(Error.prototype);
Expand All @@ -20,7 +24,11 @@ function StatusCodeError(statusCode, message) {
this.statusCode = statusCode;
this.message = statusCode + ' - ' + message;

Error.captureStackTrace(this);
if(Error.captureStackTrace){
Error.captureStackTrace(this);
} else {
Error.call(this);
}

}
StatusCodeError.prototype = Object.create(Error.prototype);
Expand Down

0 comments on commit 1d11365

Please # to comment.