Class: Freddy::Utils

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

Class Method Summary collapse

Class Method Details

.format_exception(exception) ⇒ Object



3
4
5
6
7
8
9
10
# File 'lib/freddy/utils.rb', line 3

def self.format_exception(exception)
  backtrace = exception.backtrace.map do |x|
    x.match(/^(.+?):(\d+)(|:in `(.+)')$/);
    [$1, $2, $4]
  end.join("\n")

  "#{exception.exception}\n#{backtrace}"
end

.notify(name, message, parameters = {}) ⇒ Object



12
13
14
15
16
17
18
19
20
21
# File 'lib/freddy/utils.rb', line 12

def self.notify(name, message, parameters={})
  return unless defined?(Airbrake)

  Airbrake.notify_or_ignore(
    error_class: name,
    error_message: message,
    cgi_data: ENV.to_hash,
    parameters: parameters
  )
end

.notify_exception(exception, parameters = {}) ⇒ Object



23
24
25
26
27
28
29
30
# File 'lib/freddy/utils.rb', line 23

def self.notify_exception(exception, parameters={})
  return unless defined?(Airbrake)

  Airbrake.notify_or_ignore(exception,
    cgi_data: ENV.to_hash,
    parameters: parameters
  )
end