Let a `rescue_from` handler propagate an exception instead of rendering it
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 45/100
Hướng nghiên cứu
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.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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.
- Ngôn ngữ chính
- Ruby
- Star
- 10k
- Fork
- 1.2k
- Merge trung bình
- 13 giờ 13 phút
- Pull request đã merge (30 ngày)
- 115
Chuẩn bị môi trường
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của ruby-grape/grape
-
feature request you can help
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 64/100
ruby-grape/grape#2487 · 2 bình luận · 2 reaction ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 35/100
ruby-grape/grape#2979 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
chore
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 30/100
ruby-grape/grape#2562 · 4 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
feature request
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 25/100
ruby-grape/grape#2522 · 3 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug?
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 48/100
ruby-grape/grape#2473 · 6 bình luận · 1 reaction ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của ruby-grape/grape
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
solana-foundation/pay-kit#341 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 72/100
TheOdinProject/curriculum#31427 · 3 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Mail processor needs SSL flagĐang mở
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 90/100
cyclestreets/cyclescape#1107 · 1 reaction ·
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 95/100
Maintainer thường phản hồi trong vòng 1 ngày