Class: ConvenientService::Service::Plugins::CollectsServicesInException::Middleware

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

Instance Method Summary collapse

Instance Method Details

#nextObject

Raises:

  • (StandardError)


21
22
23
24
25
26
27
28
29
# File 'lib/convenient_service/service/plugins/collects_services_in_exception/middleware.rb', line 21

def next(...)
  chain.next(...)
rescue => exception
  exception.instance_exec { define_singleton_method(:services) { @services ||= [] } } unless exception.respond_to?(:services)

  Utils::Array.limited_push(exception.services, service_details, limit: max_services_size)

  raise
end