Skip to content

Commit

Permalink
Merge pull request #234 from open-rpc/fix/jsonrpc-error-instanceof
Browse files Browse the repository at this point in the history
fix: jsonrpc error instanceof
  • Loading branch information
shanejonas authored Dec 17, 2020
2 parents e3266e6 + dc2df42 commit 86780d4
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/Error.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,9 @@ describe("Error test", () => {
const err2 = new JSONRPCError("test", 9999, "testdata");
});

it("should be able to use instanceof", () => {
const err = new JSONRPCError("test", 9999);
expect(err instanceof JSONRPCError).toBe(true);
});

});
1 change: 1 addition & 0 deletions src/Error.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export class JSONRPCError extends Error {
this.message = message;
this.code = code;
this.data = data;
Object.setPrototypeOf(this, new.target.prototype); // restore prototype chain: see https://github.com/open-rpc/client-js/issues/209
}
}

Expand Down

0 comments on commit 86780d4

Please sign in to comment.