semashkinvg / Bitmex.NET

Wrapper for BitMEX.com REST & WebSocket API
MIT License
52 stars 26 forks source link

Propogate 503, 429 Error responses #35

Closed ha07z7xe closed 5 years ago

ha07z7xe commented 5 years ago

Bitmex returns the following errors in response to overload and rate limit caps respectively: https://www.bitmex.com/app/restAPI

Is there a way to propagate this information to the application, so it can handle them appropriately?

radiant-alex commented 5 years ago

Yes, just need to slightly extend BitmexApiProxy.cs so that we can wrap such errors into special exception-classes so then you can catch and handle this on your consumer side

semashkinvg commented 5 years ago

@alex-lucid @HA07Z7XE Hi both, you would like to have different exception type for these codes, wouldn't you?

ha07z7xe commented 5 years ago

Hi @semashkinvg , actually I have propagated the StatusCode itself through BitmexApiException so that my consuming code can handle and retry - https://github.com/semashkinvg/Bitmex.NET/pull/36 , https://github.com/HA07Z7XE/Bitmex.NET/commit/b722abcd58e8a3ae6e28d223f66f5a94a6929d39 (Sorry, I did not fix my PR because I do not have a net462 environment).

My preference would be the same approach, as then other StatusCodes can also be handled from the client should the need arise.

semashkinvg commented 5 years ago

@HA07Z7XE ok, let me have a look how it could be approached

semashkinvg commented 5 years ago

@HA07Z7XE have a look at the commit attached to this issue, would it be sufficient in your case?

ha07z7xe commented 5 years ago

@semashkinvg not 100%. If possible I would like to fix my PR which has the same changes. If I fix the CI build, does my PR look ok?

There are a few related (albiet breaking) changes in there around returning rate limit data which I also require,

semashkinvg commented 5 years ago

@HA07Z7XE wow! you PR is just amazing, I dreamed to implement it half of year ago, but didn't have time to do this. Please proceed, that's absolutely great!

semashkinvg commented 5 years ago

@HA07Z7XE please run Integration tests with your own account (Api Key and secret) but don't commit them

ha07z7xe commented 5 years ago

Sure. I'll get something up soon.