Class: Racket::Utils::Exceptions::ExceptionHandler

Inherits:
Object
  • Object
show all
Defined in:
lib/racket/utils/exceptions.rb

Overview

Handles exceptions dynamically

Class Method Summary collapse

Class Method Details

.run_block(errors) ⇒ true|flase

Runs a block. If no exceptions are raised, this method returns true. If any of the provided error types are raised, this method returns false. If any other exception is raised, this method will just forward the exception.

Parameters:

  • errors (Array)

Returns:

  • (true|flase)


33
34
35
36
37
38
39
40
# File 'lib/racket/utils/exceptions.rb', line 33

def self.run_block(errors)
  raise 'Need a block' unless block_given?
  begin
    true.tap { yield }
  rescue boolean_module(errors)
    false
  end
end