Sha256: abc0c4014b3ed40ba5ac0c370f825a8fb779be6ff7dd0d139445e2632c6c88b8
Contents?: true
Size: 835 Bytes
Versions: 7
Compression:
Stored size: 835 Bytes
Contents
module Protobuf module Rpc module Middleware class ExceptionHandler include ::Protobuf::Logging attr_reader :app def initialize(app) @app = app end 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 = env.response.encode env end private # Wrap exceptions in a generic Protobuf errors unless they already are # def wrap_exception(exception) exception = RpcFailed.new(exception.message) unless exception.is_a?(PbError) exception end end end end end
Version data entries
7 entries across 7 versions & 1 rubygems