Exception: TCOMethod::AmbiguousSourceError
- Inherits:
-
StandardError
- Object
- StandardError
- TCOMethod::AmbiguousSourceError
- Defined in:
- lib/tco_method/ambiguous_source_error.rb
Overview
Exception raised when it’s not possible to reliably determine the source code of a block.
Constant Summary collapse
- MESSAGE =
Default message template.
"Could not determine source of block".freeze
Instance Attribute Summary collapse
-
#original_exception ⇒ Object
Returns the exception that this exception was created to wrap if any such exception exists.
Class Method Summary collapse
-
.from_proc(block) ⇒ AmbiguousBlockError
Create an exception from a problematic block.
-
.wrap(exception) ⇒ AmbiguousBlockError
Wrap another exception with an AmbiguousBlockError.
Instance Method Summary collapse
-
#initialize(message = MESSAGE) ⇒ AmbiguousSourceError
constructor
Creates a new instance of the exception.
Constructor Details
#initialize(message = MESSAGE) ⇒ AmbiguousSourceError
Creates a new instance of the exception.
38 39 40 |
# File 'lib/tco_method/ambiguous_source_error.rb', line 38 def initialize( = MESSAGE) super end |
Instance Attribute Details
#original_exception ⇒ Object
Returns the exception that this exception was created to wrap if any such exception exists. Used only when this exception is created to wrap another.
11 12 13 |
# File 'lib/tco_method/ambiguous_source_error.rb', line 11 def original_exception @original_exception end |
Class Method Details
.from_proc(block) ⇒ AmbiguousBlockError
Create an exception from a problematic block.
18 19 20 |
# File 'lib/tco_method/ambiguous_source_error.rb', line 18 def self.from_proc(block) new(MESSAGE + " #{block.inspect}") end |
.wrap(exception) ⇒ AmbiguousBlockError
Wrap another exception with an AmbiguousBlockError. Useful for wrapping errors raised by MethodSource.
29 30 31 32 33 |
# File 'lib/tco_method/ambiguous_source_error.rb', line 29 def self.wrap(exception) error = new(exception.) error.original_exception = exception error end |