mint icon indicating copy to clipboard operation
mint copied to clipboard

Add `humanize_error_code` generic case

Open kaiserdan opened this issue 1 year ago • 1 comments

The humanize_error_code function should have a generic case for error codes that aren't explicitly defined. I sometimes get a 70007 error which then causes an error in the module. Happy to make a PR for this if you like.

(mint 1.6.0) lib/mint/http2.ex:823: Mint.HTTP2.stream/2
(mint 1.6.0) lib/mint/http2.ex:1397: Mint.HTTP2.maybe_concat_and_handle_new_data/2
(mint 1.6.0) Lib/mint/http2. ex:1402: Mint.HTTP2.handle_new_data/3
(mint 1.6.0) lib/mint/http2/frame.ex:99: Mint.HTTP2.Frame.decode_next/2
(mint 1.6.0) lib/mint/http2/frame.ex:237: Mint.HTTP2.Frame.decode_goaway/3
(mint 1.6.0) lib/mint/http2/frame.ex:472: Mint.HTTP2.Frame.humanize_error_code (70007)
** (FunctionClauseError) no function clause matching in Mint.HTTP2.Frame.humanize_error_code/1

kaiserdan avatar Jun 13 '24 19:06 kaiserdan

@kaiserdan yes would love the help. Does the HTTP/2 spec say what to do in case of unknown errors?

whatyouhide avatar Jun 17 '24 12:06 whatyouhide

@whatyouhide I don't think it's part of the HTTP spec but rather a custom error code thats generated by some webservers or proxies

I solved it locally by adding a generic case for it it as defp humanize_error_code(_), do: :internal_error

Maybe a dedicated error code makes sense like : undefined_error, :unknown_error, :other_error, or :custom_error ?

Let me know what you prefer!

kaiserdan avatar Jul 02 '24 13:07 kaiserdan

Yeah I would like something like {:custom_error, code}. Thoughts? You're welcome to start on a PR and we can continue the discussion there 🙃

whatyouhide avatar Jul 02 '24 14:07 whatyouhide