Let a `rescue_from` handler propagate an exception instead of rendering it
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Aptitud para principiantes
- 45/100
Línea de trabajo
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.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
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.
- Lenguaje dominante
- Ruby
- Estrellas
- 10k
- Forks
- 1.2k
- Merge medio
- 13 h 13 min
- PR fusionados (30 d)
- 115
Guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de ruby-grape/grape
-
feature request you can help
Dificultad 2/5 1-3 horas Aptitud para principiantes 64/100
ruby-grape/grape#2487 · 2 comentarios · 2 reacciones ·
-
Dificultad 4/5 3-5 días Aptitud para principiantes 35/100
ruby-grape/grape#2979 · 1 comentario ·
-
chore
Dificultad 2/5 1-3 horas Aptitud para principiantes 30/100
ruby-grape/grape#2562 · 4 comentarios ·
-
feature request
Dificultad 5/5 Más de una semana Aptitud para principiantes 25/100
ruby-grape/grape#2522 · 3 comentarios ·
-
bug?
Dificultad 4/5 3-5 días Aptitud para principiantes 48/100
ruby-grape/grape#2473 · 6 comentarios · 1 reacción ·
Todos los issues de ruby-grape/grape
Issues similares
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
hanami/hanami-cli#449 ·
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
resque/resque-scheduler#826 ·
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 65/100
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100