alpaca-trade-api-js icon indicating copy to clipboard operation
alpaca-trade-api-js copied to clipboard

API calls swallow response in case of exception

Open vladtar opened this issue 3 years ago • 0 comments

Issue is here: https://github.com/alpacahq/alpaca-trade-api-js/blob/master/lib/api.js#L25-L27

If I catch an exception in the client code all I get is Request failed with status code 422 which is not useful.

What I really want is err.response.data which is { code: 42210000, message: 'notional amount must be >= 1.00' }.

I'm not sure why there is a catch there and then a rethrow of just the message in the exception. I would probably suggest removing that block altogether, or at least rethrow the full exception?

vladtar avatar Feb 22 '22 19:02 vladtar