module Bramble::ErrorHandling

Public Class Methods

rescuing(implementation) { || ... } click to toggle source

If an error is raised during the block, pass it to the implementation's `on_error` function.

# File lib/bramble/error_handling.rb, line 5
def self.rescuing(implementation)
  yield
rescue StandardError => err
  if implementation.respond_to?(:on_error)
    implementation.on_error(err)
  else
    raise(err)
  end
end