Module: Trouble

Defined in:
lib/trouble.rb,
lib/trouble/version.rb,
lib/trouble/middleware.rb,
lib/trouble/configuration.rb,
lib/trouble/configuration.rb

Overview

A generic wrapper to report errors and Exceptions.

Defined Under Namespace

Modules: VERSION Classes: Configuration, Middleware

Class Method Summary collapse

Class Method Details

.configObject

Public: Returns the the configuration instance.



28
29
30
# File 'lib/trouble/configuration.rb', line 28

def self.config
  @config ||= Configuration.new
end

.configure {|config| ... } ⇒ Object

Public: Yields the configuration instance.

Yields:



34
35
36
# File 'lib/trouble/configuration.rb', line 34

def self.configure(&block)
  yield config
end

.log(exception, metadata = nil) ⇒ Object

Public: Log the error in the logger and track as metric.

exception - An instance of an Exception metadata - An Hash with arbitrary additional information (optional)

Examples

Trouble.log RuntimeError.new
Trouble.log RuntimeError.new, some_idea_why_it_happened: "I don't know, but try this and that."

Returns nothing.



39
40
41
42
43
# File 'lib/trouble.rb', line 39

def self.log(exception,  = nil)
  exception.set_backtrace(caller) unless exception.backtrace
  (exception, )
  increment_metric
end

.notify(exception, metadata = nil) ⇒ Object

Public: Notify the developers about an Exception

exception - An instance of an Exception metadata - An Hash with arbitrary additional information (optional)

Examples

Trouble.notify RuntimeError.new
Trouble.notify RuntimeError.new, some_idea_why_it_happened: "I don't know, but try this and that."

Returns nothing.



20
21
22
23
24
25
# File 'lib/trouble.rb', line 20

def self.notify(exception,  = nil)
  exception.set_backtrace(caller) unless exception.backtrace
  notify_error_service(exception, )
  (exception, )
  increment_metric
end

.reset!Object

Public: Reset the configuration (useful for testing)



40
41
42
# File 'lib/trouble/configuration.rb', line 40

def self.reset!
  @config = nil
end