Skip to content

Questions/ideas #2

Description

@peaceful-james

I am confused about the decision to always return a tuple with first element :error from defp handle_response({:ok, %Response{status_code: scode, body: body}}).

This is here:

defp handle_response({:ok, %Response{status_code: scode, body: body}}) do

It seems strange to always return an :error tuple. What is the reasoning behind it?

For the time being, I am using this modified version of the function (which seems simple and more fitting for every use case I have ):

# other http response code
 defp handle_response({:ok, %Response{status_code: scode, body: body}}) do
    case Jason.decode(body) do
      {:ok, json} ->
        {:ok, {scode, json}}

      # return unprocessed body
      _ ->
        {:error, {scode, body}}
    end
  end

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions