Let a `rescue_from` handler propagate an exception instead of rendering it
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 45/100
Direzione di ricerca
Look at the rescue_from handling in lib/grape/middleware/error.rb and lib/grape/dsl/inside_route.rb. Understand how exceptions are caught and redispatched since #2703. The change involves adding a propagate option to rescue_from, similar to the raise_rendering_errors config. Check existing tests for rescue_from to see how to add new behavior.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Since #2703 (3.3.0) an exception raised inside a rescue_from block is caught and redispatched instead of escaping the middleware stack. That fixed #2482, and it also removed the only way an app could let a specific exception class reach Rack middleware mounted above Grape. There's no opt-out today.
The case I hit: Rails' ActiveRecord::Middleware::DatabaseSelector routes a request to a read replica, and a custom config.active_record.database_resolver can catch ActiveRecord::ReadOnlyError and retry the block against the primary. The app re-raised that error from rescue_from(:all) so the resolver upstream could do its job. On 3.3+ it no longer gets there, so the request 500s where it used to recover, and nothing notices, since the redispatch renders an ordinary 500.
env['grape.exception'] (#2855) is enough to report the exception but not to act on it, because the response is already built by then. Raising a non-StandardError does escape, but it bypasses every intervening rescue => e. Dropping rescue_from :all gives up the catch-all for everything else, and #2737 makes excluding a single class from it an ArgumentError.
#2840 made the same call for the rendering case and added Grape.config.raise_rendering_errors to opt back out. I'd like the equivalent for the handler case:
rescue_from ActiveRecord::ReadOnlyError, propagate: true
Verified the behavior above against 4.0.1. Happy to open a PR if the direction seems right.
- Lingua principale
- Ruby
- Stelle
- 10k
- Fork
- 1.2k
- Merge medio
- 13h 13m
- PR unite (30g)
- 115
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di ruby-grape/grape
-
feature request you can help
Difficoltà 2/5 1-3 ore Idoneità per principianti 64/100
ruby-grape/grape#2487 · 2 commenti · 2 reazioni ·
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 35/100
ruby-grape/grape#2979 · 1 commento ·
-
chore
Difficoltà 2/5 1-3 ore Idoneità per principianti 30/100
ruby-grape/grape#2562 · 4 commenti ·
-
feature request
Difficoltà 5/5 Più di una settimana Idoneità per principianti 25/100
ruby-grape/grape#2522 · 3 commenti ·
-
bug?
Difficoltà 4/5 3-5 giorni Idoneità per principianti 48/100
ruby-grape/grape#2473 · 6 commenti · 1 reazione ·
Tutte le issue di ruby-grape/grape
Issue simili
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
hanami/hanami-cli#449 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
resque/resque-scheduler#826 ·
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100