Sha256: 4d0c851e27c3ce269076cfe6098fd9b7b27a601ac409a77b5ff5df4b1f067bc0
Contents?: true
Size: 848 Bytes
Versions: 2
Compression:
Stored size: 848 Bytes
Contents
require "twirp/error" module RailsTwirp module ExceptionHandling extend ActiveSupport::Concern include AbstractController::Logger def process_action(*) super rescue Exception => e # We adopt the same error handling logic as Rails' standard middlewares: # 1. When we 'show exceptions' we make the exception bubble up—this is useful for testing raise e unless http_request.show_exceptions? # 2. When we want to show detailed exceptions we include the exception message in the error if http_request.get_header("action_dispatch.show_detailed_exceptions") self.response_body = Twirp::Error.internal_with(e) return end # 3. Otherwise we just return a vague internal error message self.response_body = Twirp::Error.internal("Internal error") end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
rails_twirp-0.11.0 | lib/rails_twirp/exception_handling.rb |
rails_twirp-0.10.0 | lib/rails_twirp/exception_handling.rb |