Possible unreachable case in Auth0Ex.Parse.parse
jsangilve opened this issue · 2 comments
Thanks for writing this client library.
I've been using it for a few weeks and realized that API errors are always returned as a tuple
{:error, body, http_status}
However, after having a look into the code, I found this:
auth0_ex/lib/auth0_ex/parser.ex
Line 21 in 308b96a
I think that case clause will never be reached. It probably was intended to be as follows:
{:ok, %HTTPoison.Response{body: body, status_code: status}} when status in [400, 401, 403, 404, 429] ->
{:error, Poison.decode!(body)}
If this is the case, fixing the clause would probably break the code for anyone pattern matching the {:error, body, status}
tuple on error responses.
@jsangilve thanks for pointing that out. would you be willing to make a PR to fix that? In general, I am more inclined towards not handling particular status codes response and rather giving out {:error, raw_body, status_code}
back to the consumer of this package when the response is an error. Lets just remove the {:ok, %HTTPoison.Response{body: body}, status_code: status} when status in [400, 401, 403, 404, 429] ->
clause altogether