So im working with an api and basically build an wrapper around it, so everyone can use it … and its going good, but I only cover the good way - when everything is working fine etc.
but one thing I noticed it, that I somehow have to catch errors and then return them to the user such as
400 → BadRequestException
403 → AuthException
404 → NotFoundException
429 → RateLimitException
503 → MaintenanceException
(just as an example)
here is an example http function
def get_raw_leagues(tag) do
{:ok, data} = Client.call_api("...")
data
end
While Client.call_api is just HTTPoisons Base function, just wrapped into its own module.
So my actual question here is, how can I handle f.e. an error like “api is down”, “invalid tag” etc. …