Class: Rox::Core::UserspaceUnhandledErrorInvoker

Inherits:
Object
  • Object
show all
Defined in:
lib/rox/core/error_handling/userspace_unhandled_error_invoker.rb

Instance Method Summary collapse

Constructor Details

#initialize(user_unhandler_error_handler = nil) ⇒ UserspaceUnhandledErrorInvoker

Returns a new instance of UserspaceUnhandledErrorInvoker.



6
7
8
# File 'lib/rox/core/error_handling/userspace_unhandled_error_invoker.rb', line 6

def initialize(user_unhandler_error_handler = nil)
  @user_unhandler_error_handler = user_unhandler_error_handler
end

Instance Method Details

#handler=(handler) ⇒ Object



24
25
26
# File 'lib/rox/core/error_handling/userspace_unhandled_error_invoker.rb', line 24

def handler=(handler)
  @user_unhandler_error_handler = handler
end

#invoke(exception_source, exception_trigger, exception) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/rox/core/error_handling/userspace_unhandled_error_invoker.rb', line 10

def invoke(exception_source, exception_trigger, exception)
  unless @user_unhandler_error_handler
    Logging.logger.error("User Unhandled Error Occurred, no fallback handler was set, exception ignored: #{exception}")
    return
  end

  begin
    userspace_unhandled_error_args = UserspaceUnhandledErrorArgs.new(exception_source, exception_trigger, exception)
    @user_unhandler_error_handler.call(userspace_unhandled_error_args)
  rescue StandardError => e
    Logging.logger.error("User Unhandled Error Handler itself threw an exception. original exception: #{e}")
  end
end