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

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

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Since:

  • 1.0.0

Instance Method Summary collapse

Instance Method Details

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

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

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:

Since:

  • 1.0.0



62
63
64
65
66
# File 'lib/convenient_service/service/plugins/rescues_result_unhandled_exceptions/middleware.rb', line 62

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