Skip to content

Commit

Permalink
Create ResponseError class
Browse files Browse the repository at this point in the history
  • Loading branch information
zarathustra323 committed Oct 12, 2018
1 parent 3d45a74 commit 362bc1a
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/objects/response-error.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
class ResponseError extends Error {
constructor({ result, rawResponse, rawRequest } = {}, message, ...args) {
const formatted = message ? message.replace(/^error: /i, '') : message;
super(formatted, ...args);

if (Error.captureStackTrace) {
Error.captureStackTrace(this, ResponseError);
}

this.result = result;
this.rawResponse = rawResponse;
this.rawRequest = rawRequest;
}
}

module.exports = ResponseError;

0 comments on commit 362bc1a

Please sign in to comment.