Skip to content

Create exception hierarchy based on status code classes #4

@mfrister

Description

@mfrister

Currently, there is no way to catch all exceptions for a specific class of status codes.

A client might e.g. want to retry requests based on the status code class. It might e.g. make sense to retry a request returning a 5xx server error, but not to retry the request for a 4xx client error (that would fail again anyway with the same parameters).

Such a hierarchy would also allow us to better process status codes that don't have a specific exception for.

Suggestions for a hierarchy:

  • Base - allow catching all Grac-related exceptions
    • ClientException - already exists, keep for compatibility, currently inherits from StandardError
      • ClientError (4xx)
        • BadRequest (400)
        • Forbidden (403)
        • NotFound (404)
        • Conflict (409)
      • ServerError (5xx)
        • ServiceError - we already have this and don't want to break applications catching these (might have to add it above ServerError)
          • InternalServerError (500)
    • RequestFailed - already exists, currently inherits from StandardError
      • ServiceTimeout - already exists
    • InvalidContent - already exists, currently inherits from StandardError

We'll have to extend this hierarchy when adding more status codes (see #1). We don't explicitly deal with redirects yet, so nothing on 3xx codes here.

Still missing:

  • Handling unknown 2xx and 3xx status codes

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions