krazkidd / kdeck

Desktop client for Kalshi event trading platform
GNU General Public License v3.0
1 stars 0 forks source link

Add API error message handling #11

Closed krazkidd closed 2 weeks ago

krazkidd commented 3 weeks ago

All REST API endpoints can return 400- or 500-level errors with a generic JSON object. It is not an "exceptional" case when this happens. We don't necessarily want to throw control back up to some arbitrary caller. We should try to handle these errors in normal control flow rather than in a catch block. We can still throw if the API response is out of spec (e.g. malformatted JSON).

The returned JSON structure is the same for all:

{
    "code": "",
    "details": "",
    "message": ""
}

Special handling should be considered for certain codes. For example, see #14.