Module: Cuprum::ExceptionHandling
- Defined in:
- lib/cuprum/exception_handling.rb
Overview
Utility module for handling uncaught exceptions in commands.
This functionality can be temporarily disabled by setting the ENV flag; this can be used to debug issues when testing commands.
Instance Method Summary collapse
-
#call(*args, **kwargs) ⇒ Cuprum::Result
Wraps the #call method with a rescue clause matching any StandardError.
Instance Method Details
#call(*args, **kwargs) ⇒ 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.
49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/cuprum/exception_handling.rb', line 49 def call(*args, **kwargs, &) super rescue StandardError => exception raise exception if ENV['CUPRUM_RERAISE_EXCEPTIONS'] error = Cuprum::Errors::UncaughtException.new( exception:, message: "uncaught exception in #{self.class.name} - " ) failure(error) end |