Skip to content

Commit

Permalink
Remove API error validation
Browse files Browse the repository at this point in the history
Signed-off-by: tiksan <webmaster@deek.sh>
  • Loading branch information
dssecret committed Sep 13, 2024
1 parent dab0588 commit 490d2bc
Showing 1 changed file with 0 additions and 14 deletions.
14 changes: 0 additions & 14 deletions lib/tornex/api.ex
Original file line number Diff line number Diff line change
Expand Up @@ -52,25 +52,11 @@ defmodule Tornex.API do
)
end

@spec validate_api_error(Map) :: {:ok, Map} | {:error, {:api, Integer}}
defp validate_api_error(response) when is_map(response) do
case response["error"] do
nil -> {:ok, response}
%{"code" => error_code} -> {:error, {:api, error_code}}
end
end

@spec validate_api_error({:error, any()}) :: {:error, any()}
defp validate_api_error({:error, error}) do
{:error, error}
end

@spec torn_get(Query.t()) :: {:ok, Map} | {:error, {:api, Integer}} | {:error, any()}
def torn_get(query) do
case get(query_to_url(query)) do
{:ok, response} ->
response.body
|> validate_api_error()

{:error, _} ->
{:error, :unknown}
Expand Down

0 comments on commit 490d2bc

Please sign in to comment.