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

Handle `start_pool` error without crashing #89

Closed reisub closed 2 years ago

reisub commented 3 years ago

When Mojito can't start a new pool quick enough, it will throw an exception like this:

{
  {:badmatch, {:error, %Mojito.Error{message: nil, reason: :checkout_timeout}}}, 
  [
    {Mojito.Pool.Poolboy, :do_request, 3, [file: 'lib/mojito/pool/poolboy.ex', line: 36]},
    {Mojito, :request, 1, [file: 'lib/mojito.ex', line: 199]},
    <... rest of stack trace ...>
}

Since the other case for :checkout_timeout returns the error without crashing, this was surprising behavior for me and it seems like a bug. I'm proposing to fix it by returning the error according to the spec.

Thanks in advance for taking the time to review this!

reisub commented 3 years ago

Hi there, any chance we could get this small change merged in?