Module: Cuprum::ExceptionHandling
- Defined in:
- lib/cuprum/exception_handling.rb
Overview
Utility module for handling uncaught exceptions in commands.
Instance Method Summary collapse
-
#call(*args, **kwargs, &block) ⇒ Cuprum::Result
Wraps the #call method with a rescue clause matching any StandardError.
Instance Method Details
#call(*args, **kwargs, &block) ⇒ Cuprum::Result
Wraps the #call method with a rescue clause matching any StandardError.
If a StandardError or subclass thereof is raised and not caught by #call, then ExceptionHandling will rescue the exception and return a failing Cuprum::Result with a Cuprum::Errors::UncaughtException error.
42 43 44 45 46 47 48 49 50 |
# File 'lib/cuprum/exception_handling.rb', line 42 def call(*args, **kwargs, &block) super rescue StandardError => exception error = Cuprum::Errors::UncaughtException.new( exception: exception, message: "uncaught exception in #{self.class.name} - " ) failure(error) end |