Class: FailtaleReporter::Error

Inherits:
Object
  • Object
show all
Defined in:
lib/failtale_reporter/error.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(exception, ctxs = []) ⇒ Error

Returns a new instance of Error.



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/failtale_reporter/error.rb', line 12

def initialize(exception, ctxs=[])
  self.api_token = FailtaleReporter.api_token
  self.reporter  = FailtaleReporter.default_reporter

  self.name = "#{exception.class} #{exception.message}"
  self.description = exception.message
  self.backtrace = FailtaleReporter.clean_backtrace(exception.backtrace).join("\n")
  self.environment = ENV.to_hash
  self.hash_string = Digest::SHA1.hexdigest(
    [exception.class, exception.backtrace.first].join('--')
  )
  FailtaleReporter.collect_information(self, ctxs)

  self.backtrace = self.backtrace.inspect unless self.backtrace.is_a? String
  self.environment = self.environment.inject({}) do |m,(k,v)|
    k = k.inspect unless k.is_a? String
    v = v.inspect unless v.is_a? String
    m[k] = v
    m
  end
end

Instance Attribute Details

#api_tokenObject

Returns the value of attribute api_token.



3
4
5
# File 'lib/failtale_reporter/error.rb', line 3

def api_token
  @api_token
end

#backtraceObject

Returns the value of attribute backtrace.



9
10
11
# File 'lib/failtale_reporter/error.rb', line 9

def backtrace
  @backtrace
end

#descriptionObject

Returns the value of attribute description.



7
8
9
# File 'lib/failtale_reporter/error.rb', line 7

def description
  @description
end

#environmentObject

Returns the value of attribute environment.



10
11
12
# File 'lib/failtale_reporter/error.rb', line 10

def environment
  @environment
end

#hash_stringObject

Returns the value of attribute hash_string.



4
5
6
# File 'lib/failtale_reporter/error.rb', line 4

def hash_string
  @hash_string
end

#nameObject

Returns the value of attribute name.



5
6
7
# File 'lib/failtale_reporter/error.rb', line 5

def name
  @name
end

#propertiesObject

Returns the value of attribute properties.



8
9
10
# File 'lib/failtale_reporter/error.rb', line 8

def properties
  @properties
end

#reporterObject

Returns the value of attribute reporter.



6
7
8
# File 'lib/failtale_reporter/error.rb', line 6

def reporter
  @reporter
end

Instance Method Details

#to_paramObject



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/failtale_reporter/error.rb', line 34

def to_param
  { :report =>
    { :project => {
      :api_token => self.api_token
    },:error => {
      :hash_string => self.hash_string
    },:occurence => {
      :name => self.name,
      :reporter => self.reporter,
      :description => self.description,
      :backtrace => self.backtrace,
      :properties => self.environment
    } }
  }
end