Cobenian / raygun

A raygun client for Elixir
Apache License 2.0
19 stars 15 forks source link

Handle HTTP 429 error response from raygun #34

Open akash-akya opened 2 years ago

akash-akya commented 2 years ago

Raygun can return 429 to rate-limit which is causing CaseClauseError.

In our case, we have generic error handler which sends all exceptions to raygun and because of this exception we are recursively trying to send error and failing. Ending up in a recursive loop

Sample error:

** (CaseClauseError) no case clause matching: {:ok, %HTTPoison.Response{body: "", headers: [{"Date", "Tue, 11 Oct 2022 12:03:42 GMT"}, {"Content-Type", "application/json"}, {"Content-Length", "0"}, {"Connection", "keep-alive"}, {"Access-Control-Allow-Origin", "*"}], request_url: "https://api.raygun.io/entries", status_code: 429}}
    (raygun 0.3.2) lib/raygun.ex:54: Raygun.send_report/1
    (stdlib 3.12.1) proc_lib.erl:234: :proc_lib.init_p/3

I think we can just pattern match and return {:error, :too_many_request}

I guess we should also handle 413 which we might get based on API spec