Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Raise error for all 4xx and 5xx response status codes #639

@reuben453

Description

@reuben453

Currently, errors are raised for specific HTTP status codes (error.rb#L142). This allows us to have specially named classes like BadRequest (for 400 status code).

But it means that for any status code not in the map, no error is raised. This can cause subtle bugs when a 4xx or 5xx status code is received but it doesn't raise an error. This is especially problematic for APIs that don't return a JSON response, such as the file_contents method.

What do you think of raising an error for any 4xx and 5xx status code?

  • If the status code has a special class associated with it, we can raise an error of that class (as happens now).
  • But if there is no special class available, raise a ResponseError.

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