diff options
-rw-r--r-- | lib/open_ai.ex | 9 |
1 files changed, 1 insertions, 8 deletions
diff --git a/lib/open_ai.ex b/lib/open_ai.ex index e28a610..81f12f4 100644 --- a/lib/open_ai.ex +++ b/lib/open_ai.ex @@ -12,15 +12,8 @@ defmodule OpenAi do {:ok, data} <- Poison.decode(body) do {:ok, data} else - {:ok, %HTTPoison.Response{status_code: 400}} -> {:error, :bad_request} - {:ok, %HTTPoison.Response{status_code: 402}} -> {:error, :payment_required} - {:ok, %HTTPoison.Response{status_code: 403}} -> {:error, :forbidden} - {:ok, %HTTPoison.Response{status_code: 429}} -> {:error, :too_many_requests} - {:ok, %HTTPoison.Response{status_code: 500}} -> {:error, :internal_error} - {:ok, %HTTPoison.Response{status_code: 503}} -> {:error, :service_unavailable} - {:ok, %HTTPoison.Response{status_code: code}} -> {:error, String.to_atom("http #{code}")} + {:ok, %HTTPoison.Response{status_code: code}} -> {:error, Plug.Conn.Status.reason_atom(code)} {:error, %HTTPoison.Error{reason: reason}} -> {:error, reason} - error -> error end end |