Class: ConvenientService::Service::Plugins::RescuesResultUnhandledExceptions::Middleware

Inherits:
MethodChainMiddleware
  • Object
show all
Defined in:
lib/convenient_service/service/plugins/rescues_result_unhandled_exceptions/middleware.rb

Instance Method Summary collapse

Instance Method Details

#next(*args, **kwargs, &block) ⇒ ConvenientService::Service::Plugins::HasJSendResult::Entities::Result

Note:

This middleware can be used for both instance and class ‘:result` methods.

Examples:

Usage for instance ‘:result`.


class Service
  include ConvenientService::Standard::Config

  middlewares :result do
    use ConvenientService::Plugins::Service::RescuesResultUnhandledExceptions::Middleware
  end
end

Usage for class ‘:result`.


class Service
  include ConvenientService::Standard::Config

  middlewares :result, scope: :class do
    use ConvenientService::Plugins::Service::RescuesResultUnhandledExceptions::Middleware
  end
end

Max backtrace size can be configured.


class Service
  include ConvenientService::Standard::Config

  middlewares :result do
    use ConvenientService::Plugins::Service::RescuesResultUnhandledExceptions::Middleware.with(max_backtrace_size: 1_000)
  end
end

Parameters:

  • args (Array<Object>)
  • kwargs (Hash{Symbol => Object})
  • block (Proc, nil)

Returns:



56
57
58
59
60
# File 'lib/convenient_service/service/plugins/rescues_result_unhandled_exceptions/middleware.rb', line 56

def next(*args, **kwargs, &block)
  chain.next(*args, **kwargs, &block)
rescue => exception
  result_from_exception(exception, *args, **kwargs, &block)
end