appcues / mojito

An easy-to-use Elixir HTTP client, built on the low-level Mint library.
https://hexdocs.pm/mojito/Mojito.html
MIT License
349 stars 34 forks source link

More friendly API to deal with errors #71

Closed mbenatti closed 2 years ago

mbenatti commented 4 years ago

I tested your library and notice that I can´t parse error response easily, because the library doesn't handle/parse it to a common contract.

Example of errors doing requests:

%Mojito.Error{message: "invalid URL"}

%Mojito.Error{reason: %Mint.TransportError{reason: :nxdomain}}}

A common contract could be like this:

%Mojito.Error{reason: :invalid_url, message: "invalid URL"}

%Mojito.Error{reason: :nx_domain, details: %Mint.TransportError{reason: :nxdomain}}

%Mojito.Error{reason: :some_other_error}
gamache commented 3 years ago

Hi @mbenatti! You are absolutely correct that Mojito's errors need to take a more consistent shape. It's a breaking change, which is tough, but IMO this is something we need to solve prior to or as part of a 1.0 release. I'll keep this issue open to track progress.

ntenczar commented 2 years ago

Hi! This project is now deprecated:

We recommend that you use Finch which is also built on Mint. The creator of Finch has an excellent writeup here describing the problems with Mojito, and as a result we use Finch internally at Appcues now.