diff --git a/apps/core/lib/core/clients/hydra.ex b/apps/core/lib/core/clients/hydra.ex index d696a723c..9615ef797 100644 --- a/apps/core/lib/core/clients/hydra.ex +++ b/apps/core/lib/core/clients/hydra.ex @@ -129,7 +129,7 @@ defmodule Core.Clients.Hydra do do: {:ok, Poison.decode!(body, as: type)} defp handle_response(error, _) do Logger.error "Failed to call hydra: #{inspect(error)}" - {:error, :unauthorized} + {:error, hydra_error(error)} end defp user_details(user) do @@ -156,5 +156,10 @@ defmodule Core.Clients.Hydra do defp conf(key), do: Application.get_env(:core, __MODULE__)[key] + defp hydra_error({:error, _}), do: {:error, "internal network error"} + defp hydra_error({:ok, %HTTPoison.Response{status_code: code, body: body}}) do + {:error, "hydra error: code=#{code}, body=#{body}"} + end + defp headers(), do: [{"accept", "application/json"}, {"content-type", "application/json"}] end