Module: Exceptional

Defined in:
lib/exceptional.rb,
lib/exceptional/config.rb,
lib/exceptional/remote.rb,
lib/exceptional/catcher.rb,
lib/exceptional/railtie.rb,
lib/exceptional/startup.rb,
lib/exceptional/version.rb,
lib/exceptional/alert_data.rb,
lib/exceptional/log_factory.rb,
lib/exceptional/exception_data.rb,
lib/exceptional/integration/tester.rb,
lib/exceptional/integration/alerter.rb,
lib/exceptional/rack_exception_data.rb,
lib/exceptional/application_environment.rb,
lib/exceptional/controller_exception_data.rb,
lib/exceptional/integration/exception_middleware.rb

Defined Under Namespace

Modules: ExceptionMiddleware, Integration, Rake Classes: Alert, AlertData, ApplicationEnvironment, Catcher, Config, ControllerExceptionData, ExceptionData, LogFactory, RackExceptionData, Railtie, Remote, Startup, StartupException

Constant Summary collapse

PROTOCOL_VERSION =
5
CLIENT_NAME =
'getexceptional-gem'
ENVIRONMENT_FILTER =
[]
VERSION =
'2.0.33'

Class Method Summary collapse

Class Method Details

.clear!Object



62
63
64
# File 'lib/exceptional.rb', line 62

def self.clear!
  Thread.current[:exceptional_context] = nil
end

.configure(api_key) ⇒ Object



31
32
33
# File 'lib/exceptional.rb', line 31

def self.configure(api_key)
  Exceptional::Config.api_key = api_key
end

.context(hash = {}) ⇒ Object



66
67
68
69
70
# File 'lib/exceptional.rb', line 66

def self.context(hash = {})
  Thread.current[:exceptional_context] ||= {}
  Thread.current[:exceptional_context].merge!(hash)
  self
end

.handle(exception, name = nil) ⇒ Object



35
36
37
# File 'lib/exceptional.rb', line 35

def self.handle(exception, name=nil)
  Exceptional::Catcher.handle(exception, name)
end

.loggerObject



27
28
29
# File 'lib/exceptional.rb', line 27

def self.logger
  ::Exceptional::LogFactory.logger
end

.rescue(name = nil, context = nil, &block) ⇒ Object



39
40
41
42
43
44
45
46
47
48
# File 'lib/exceptional.rb', line 39

def self.rescue(name=nil, context=nil, &block)
  begin
    self.context(context) unless context.nil?
    block.call
  rescue Exception => e
    Exceptional::Catcher.handle(e,name)
  ensure
    self.clear!
  end
end

.rescue_and_reraise(name = nil, context = nil, &block) ⇒ Object



50
51
52
53
54
55
56
57
58
59
60
# File 'lib/exceptional.rb', line 50

def self.rescue_and_reraise(name=nil, context=nil, &block)
  begin
    self.context(context) unless context.nil?
    block.call
  rescue Exception => e
    Exceptional::Catcher.handle(e,name)
    raise(e)
  ensure
    self.clear!      
  end
end