Class: Errordeck::Exception

Inherits:
Object
  • Object
show all
Defined in:
lib/errordeck/errordeck/issue/exception.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(type, value, stacktrace, module_name, thread_id) ⇒ Exception



7
8
9
10
11
12
13
# File 'lib/errordeck/errordeck/issue/exception.rb', line 7

def initialize(type, value, stacktrace, module_name, thread_id)
  @type = type
  @value = value
  @stacktrace = stacktrace
  @module = module_name
  @thread_id = thread_id
end

Instance Attribute Details

#moduleObject

Returns the value of attribute module.



5
6
7
# File 'lib/errordeck/errordeck/issue/exception.rb', line 5

def module
  @module
end

#stacktraceObject

Returns the value of attribute stacktrace.



5
6
7
# File 'lib/errordeck/errordeck/issue/exception.rb', line 5

def stacktrace
  @stacktrace
end

#thread_idObject

Returns the value of attribute thread_id.



5
6
7
# File 'lib/errordeck/errordeck/issue/exception.rb', line 5

def thread_id
  @thread_id
end

#typeObject

Returns the value of attribute type.



5
6
7
# File 'lib/errordeck/errordeck/issue/exception.rb', line 5

def type
  @type
end

#valueObject

Returns the value of attribute value.



5
6
7
# File 'lib/errordeck/errordeck/issue/exception.rb', line 5

def value
  @value
end

Class Method Details

.parse_from_exception(exception, project_root) ⇒ Object



15
16
17
18
19
20
21
22
23
# File 'lib/errordeck/errordeck/issue/exception.rb', line 15

def self.parse_from_exception(exception, project_root)
  exception_type = exception.class.to_s
  exception_value = exception.message
  exception_stacktrace = Errordeck::Stacktrace.parse_from_backtrace(exception.backtrace, project_root)
  exception_module = exception_type.split("::")[0]
  exception_thread_id = Thread.current.object_id

  [new(exception_type, exception_value, exception_stacktrace, exception_module, exception_thread_id)]
end

Instance Method Details

#as_json(*_options) ⇒ Object



25
26
27
28
29
30
31
32
33
# File 'lib/errordeck/errordeck/issue/exception.rb', line 25

def as_json(*_options)
  {
    type: @type,
    value: @value,
    stacktraces: @stacktrace,
    module: @module,
    thread_id: @thread_id
  }
end

#to_json(*options) ⇒ Object



35
36
37
# File 'lib/errordeck/errordeck/issue/exception.rb', line 35

def to_json(*options)
  JSON.generate(as_json, *options)
end