fireblocks/fireblocks-sdk-js

[Bug] SDK not returning any errorcodes

Closed this issue · 2 comments

The bug
according to the docs I am supposed to get an ErrorCode whenever something goes wrong. Instead I only get the HTTP status code ex.400 in the status l like so:
{ "message":"Request failed with status code 400", "name":"AxiosError", "config":{ ... }, "code":"ERR_BAD_REQUEST", "status":400 }
This makes catching errors very difficult.

My code
try{ const depositAddresses = await fireblocks.getDepositAddresses(vId, aId); } catch(error){ return res.status(500).json({ 'error':JSON.stringify(error) }); }
Version:

  • fireblocks-sdk version: 3.1.3

Hey, the SDK throws an AxiosError
The error itself contains the field .response

So getting the error code will be via:

error.response.data.code

documentation for handling axios errors

This is working thank you!