Class: Flightdeck::ErrorSummary

Inherits:
Object
  • Object
show all
Defined in:
app/models/flightdeck/error_summary.rb

Overview

A failed execution's error column is JSON that can run to many kilobytes once a backtrace is in it. List views only ever read a bounded prefix of it, which means the JSON is usually truncated mid-string — so parse when we can and fall back to scanning for the two fields we need.

Constant Summary collapse

UNKNOWN =
"UnknownError"

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(raw) ⇒ ErrorSummary

Returns a new instance of ErrorSummary.



21
22
23
# File 'app/models/flightdeck/error_summary.rb', line 21

def initialize(raw)
  @exception_class, @message = extract(raw)
end

Instance Attribute Details

#exception_classObject (readonly)

Returns the value of attribute exception_class.



11
12
13
# File 'app/models/flightdeck/error_summary.rb', line 11

def exception_class
  @exception_class
end

#messageObject (readonly)

Returns the value of attribute message.



11
12
13
# File 'app/models/flightdeck/error_summary.rb', line 11

def message
  @message
end

Class Method Details

.noneObject



17
18
19
# File 'app/models/flightdeck/error_summary.rb', line 17

def self.none
  new(nil)
end

.parse(raw) ⇒ Object



13
14
15
# File 'app/models/flightdeck/error_summary.rb', line 13

def self.parse(raw)
  new(raw)
end

Instance Method Details

#group_keyObject



29
30
31
# File 'app/models/flightdeck/error_summary.rb', line 29

def group_key
  exception_class.presence || UNKNOWN
end

#present?Boolean

Returns:

  • (Boolean)


25
26
27
# File 'app/models/flightdeck/error_summary.rb', line 25

def present?
  exception_class.present?
end

#to_sObject



33
34
35
36
37
# File 'app/models/flightdeck/error_summary.rb', line 33

def to_s
  return "" unless present?

  message.present? ? "#{exception_class}: #{message}" : exception_class
end