• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

ruby-grape / grape / 25569862791 / 17
97%
master: 97%

Build:
Build:
LAST BUILD BRANCH: fix/recompile-settings-mutation-race
DEFAULT BRANCH: master
Ran 08 May 2026 05:32PM UTC
Files 158
Run time 6s
Badge
Embed ▾
README BADGES
x

If you need to use a raster PNG badge, change the '.svg' to '.png' in the link

Markdown

Textile

RDoc

HTML

Rst

08 May 2026 05:31PM UTC coverage: 95.583% (-0.05%) from 95.633%
25569862791.17

Pull #2703

github

ericproulx
Catch and route exceptions raised inside rescue_from blocks

Resolves #2482. Today, an exception raised inside a `rescue_from`
block bubbles up uncaught and produces the Rack default 500 page,
which means deliberate re-raises (a common pattern for translating
one exception class into another) don't compose with the rest of a
user's `rescue_from` configuration, and accidental crashes inside a
handler are not framed as Grape responses.

The middleware now wraps the user's handler invocation with a
StandardError rescue and, on raise, routes the new exception through
one of three paths:

  1. If the re-raised exception's class has a registered `rescue_from`
     handler, run it (with `redispatched: true` so a second raise stops
     the chain — bounded at one redispatch to prevent loops).
  2. If the re-raised exception is a `Grape::Exceptions::Base` subclass,
     render it via the default Grape error path with its own `status`
     and `message`. Inheritance signals the message is part of the API
     contract.
  3. Otherwise, fall through to `safe_default`: log the original
     exception via the API's logger, expose it on
     `env['grape.exception']` for upstream Rack middleware to observe,
     and render `Grape::Exceptions::InternalServerError` (status 500,
     generic message). The original exception's message is never
     surfaced to the API consumer in this branch.

Also adds:
  - `Grape::Exceptions::InternalServerError` — i18n-backed safe stand-in.
  - `Grape::Env::GRAPE_EXCEPTION` — env key carrying the original.
  - `oneof: 'does not match...'` removed (was on a different branch).

Existing behaviour preserved when the handler returns a non-Response
non-error value (still produces `InvalidResponse` via the default
handler).

UPGRADING note + README rescue_from section updated to document the
new behaviour and the registered-handler escape hatch for users who
want raw exception messages exposed (e.g. development mode).

Co-Authored-By: Claud... (continued)
Pull Request #2703: Catch exceptions raised inside rescue_from blocks (#2482)

1064 of 1177 branches covered (90.4%)

Branch coverage included in aggregate %.

3394 of 3487 relevant lines covered (97.33%)

1001.17 hits per line

Source Files on job run-3.4-gemfiles/rails_7_2.gemfile - 25569862791.17
  • Tree
  • List 158
  • Changed 2
  • Source Changed 2
  • Coverage Changed 2
Coverage ∆ File Lines Relevant Covered Missed Hits/Line Branch Hits Branch Misses
  • Back to Build 25569862791
  • b91eb41b on github
  • Prev Job for on fix/rescue-from-internal-errors-2482 (#25564552185.17)
  • Next Job for on fix/rescue-from-internal-errors-2482 (#25570206807.14)
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc