Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow specifying a handler for grape_exceptions #2342

Merged
merged 7 commits into from
Jul 3, 2023

Commits on Jun 27, 2023

  1. Allow specifying a handler for grape_exceptions

    This allows you to customize the format of the error response for grape exceptions:
    
    For example, you could do something like this:
    
    ```rb
    rescue_from :grape_exceptions do |e|
      error!({ errors: [{ code: 'Error', message: e.message.squish }] }, e.status)
    end
    ```
    
    which would render like this:
    
    ```
    {
      "errors": [
        {
          "code": "Error",
          "message": "Problem: message body does not match declared format Resolution: when specifying application/json as content-type, you must pass valid application/json in the request's 'body'"
        }
      ]
    }
    ```
    mscrivo committed Jun 27, 2023
    Configuration menu
    Copy the full SHA
    fa16b0e View commit details
    Browse the repository at this point in the history

Commits on Jun 29, 2023

  1. match format

    mscrivo committed Jun 29, 2023
    Configuration menu
    Copy the full SHA
    b595f6f View commit details
    Browse the repository at this point in the history
  2. Fix issue caught by tests

    mscrivo committed Jun 29, 2023
    Configuration menu
    Copy the full SHA
    dcc16e3 View commit details
    Browse the repository at this point in the history
  3. Update README & CHANGELOG

    mscrivo committed Jun 29, 2023
    Configuration menu
    Copy the full SHA
    0bc6579 View commit details
    Browse the repository at this point in the history
  4. Add spec to demonstrate usage

    mscrivo committed Jun 29, 2023
    Configuration menu
    Copy the full SHA
    6fa44b1 View commit details
    Browse the repository at this point in the history
  5. Fix rubocop offenses

    mscrivo committed Jun 29, 2023
    Configuration menu
    Copy the full SHA
    fc10f59 View commit details
    Browse the repository at this point in the history

Commits on Jul 1, 2023

  1. Fix rubocop offences

    mscrivo committed Jul 1, 2023
    Configuration menu
    Copy the full SHA
    417ff32 View commit details
    Browse the repository at this point in the history