Class: Protobuf::Rpc::Middleware::ExceptionHandler
- Inherits:
-
Object
- Object
- Protobuf::Rpc::Middleware::ExceptionHandler
- Includes:
- Logging
- Defined in:
- lib/protobuf/rpc/middleware/exception_handler.rb
Instance Attribute Summary collapse
-
#app ⇒ Object
readonly
Returns the value of attribute app.
Instance Method Summary collapse
- #_call(env) ⇒ Object
- #call(env) ⇒ Object
-
#initialize(app) ⇒ ExceptionHandler
constructor
A new instance of ExceptionHandler.
Methods included from Logging
initialize_logger, #log_exception, #log_signature, #logger, #sign_message
Constructor Details
#initialize(app) ⇒ ExceptionHandler
Returns a new instance of ExceptionHandler.
9 10 11 |
# File 'lib/protobuf/rpc/middleware/exception_handler.rb', line 9 def initialize(app) @app = app end |
Instance Attribute Details
#app ⇒ Object (readonly)
Returns the value of attribute app.
7 8 9 |
# File 'lib/protobuf/rpc/middleware/exception_handler.rb', line 7 def app @app end |
Instance Method Details
#_call(env) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/protobuf/rpc/middleware/exception_handler.rb', line 17 def _call(env) app.call(env) rescue => exception log_exception(exception) # Rescue exceptions, re-wrap them as generic Protobuf errors, # and encode them env.response = wrap_exception(exception) env.encoded_response = wrap_and_encode_with_server(env.response, env) env end |
#call(env) ⇒ Object
13 14 15 |
# File 'lib/protobuf/rpc/middleware/exception_handler.rb', line 13 def call(env) dup._call(env) end |