Skip to content

Commit

Permalink
fix: error.toString shows object Object
Browse files Browse the repository at this point in the history
  • Loading branch information
denwilliams committed Jan 15, 2024
1 parent d5f4d35 commit 2ba7e2d
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion lib/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,9 @@ class RpcResponseError {
writable: true,
});

// .message .code .type .expose .instance .type are applied here
Object.assign(this, responseBody);
if (!this.source) this.source = [];

this.source = [source, ...(this.source || [])];

Object.defineProperty(this, "stack", {
Expand All @@ -138,6 +139,12 @@ class RpcResponseError {
writable: true,
});
}

toString() {
// defineProperty not recognized by typescript, nor is the result of assign recognizable
const { name, message, instance } = this as any;
return `${name}: ${message} [${instance}]`;
}
}

export class RPCClient extends BaseClient {
Expand Down

0 comments on commit 2ba7e2d

Please sign in to comment.