pusher / pusher-http-ruby

Ruby library for Pusher Channels HTTP API
https://pusher.com/channels
MIT License
664 stars 123 forks source link

Improve Pusher::Error for server side errors #143

Closed quentin-sommer closed 5 years ago

quentin-sommer commented 5 years ago

Hi,

Pusher raises "Unknown error (status code #{status_code}): #{body}"

for any error code greater than 413. Is there a specific reason for this behaviour? I think having the default http error code message would be more helpful to identify the problem.

annzenkina commented 5 years ago

Hey there,

Right now we are reporting the error code and message to the user in the exception. I'm not sure I understand why is this needed. Is it possible for you to create a proof-of-concept PR to show us what you mean?

Also, it would be great to get an example of your code that demonstrates why this would be useful.

quentin-sommer commented 5 years ago

My bad, I don't think what I wanted to do is possible. I wanted to display the default message corresponding to the HTTP status code instead of "unknown error"

For example if the status code was 502 the lib would raise something like

raise Error, "502: Bad Gateway"

instead of

raise Error, "Unknown error (status code 502): Bad Gateway"

But I see now that there is no guarantee about the body message so I guess it's best to keep it like this