Skip to content

Handle 500 errors from HCloud API #2

@samrat

Description

@samrat

Hello,

Thanks for this library. I sometimes see HTTP 500 responses from the HCloud API which results in a Jason.DecodeError:

Jason.DecodeError: unexpected byte at position 0: 0x3C ("<")
  File "lib/jason.ex", line 92, in Jason.decode!/2
  File "lib/httpoison/base.ex", line 977, in HTTPoison.Base.response/8
  File "lib/hcloud.ex", line 63, in ClusterHcloud.Hcloud.get_network_id/2
  File "lib/strategy/labels.ex", line 108, in ClusterHcloud.Strategy.Labels.get_nodes/1
  File "lib/strategy/labels.ex", line 58, in ClusterHcloud.Strategy.Labels.load/1
  File "lib/strategy/labels.ex", line 54, in ClusterHcloud.Strategy.Labels.handle_info/2
  File "gen_server.erl", line 2345, in :gen_server.try_handle_info/3
  File "gen_server.erl", line 2433, in :gen_server.handle_msg/6

Looks like the HTTPoison parse_response_body gets called even when the status is non-200. Implementing parse_response might be a better solution instead:

edgurgel/httpoison#57 (comment)

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