Module: Occi::Core::Helpers::ErrorHandler
- Included in:
- Parsers::BaseParser, Parsers::Json::ActionInstance, Parsers::Json::Category, Parsers::Json::Entity, Parsers::Text::Entity, Parsers::Text::Location
- Defined in:
- lib/occi/core/helpers/error_handler.rb
Overview
Introduces additional error handling functions to the receiver class and its instnaces.
Class Method Summary collapse
-
.included(klass) ⇒ Object
:nodoc:.
Instance Method Summary collapse
-
#handle(klass) ⇒ Object
Wraps potential exceptions raised in the given block in the specified exception class.
Class Method Details
.included(klass) ⇒ Object
:nodoc:
23 24 25 |
# File 'lib/occi/core/helpers/error_handler.rb', line 23 def self.included(klass) klass.extend self end |
Instance Method Details
#handle(klass) ⇒ Object
Wraps potential exceptions raised in the given block in the specified exception class. Internal exception can be later exposed via ‘Exception#cause`.
13 14 15 16 17 18 19 20 |
# File 'lib/occi/core/helpers/error_handler.rb', line 13 def handle(klass) raise 'You have to provide a block' unless block_given? begin yield # do whatever you need to do rescue StandardError => ex raise klass, ex. end end |