Skip to content

Commit

Permalink
chore: cast to v2ResponseBody
Browse files Browse the repository at this point in the history
  • Loading branch information
dfx-json committed Oct 23, 2024
1 parent 00475fc commit e096793
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions packages/agent/src/errors.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
import { Principal } from '@dfinity/principal';
import { QueryResponseRejected, ReplicaRejectCode, SubmitResponse } from './agent/api';
import {
QueryResponseRejected,
ReplicaRejectCode,
SubmitResponse,
v2ResponseBody,
} from './agent/api';
import { RequestId } from './request_id';
import { toHex } from './utils/buffer';

/**
* An error that happens in the Agent. This is the root of all errors and should be used
* everywhere in the Agent code (this package).
*
* @todo https://github.com/dfinity/agent-js/issues/420
*/
export class AgentError extends Error {
Expand Down Expand Up @@ -72,13 +76,13 @@ export class UpdateCallRejectedError extends ActorCallError {
'Request ID': toHex(requestId),
...(response.body
? {
...(response.body.error_code
...((response.body as v2ResponseBody).error_code
? {
'Error code': response.body.error_code,
'Error code': (response.body as v2ResponseBody).error_code,
}
: {}),
'Reject code': String(response.body.reject_code),
'Reject message': response.body.reject_message,
'Reject code': String((response.body as v2ResponseBody).reject_code),
'Reject message': (response.body as v2ResponseBody).reject_message,
}
: {
'HTTP status code': response.status.toString(),
Expand Down

0 comments on commit e096793

Please sign in to comment.