alpacahq / alpaca-trade-api-js

Node.js library for Alpaca Trade API.

Home Page:https://www.npmjs.com/package/@alpacahq/alpaca-trade-api

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

API calls swallow response in case of exception

vladtar opened this issue · 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?