Class: Kreuzberg::Errors::PanicContext
- Inherits:
-
Object
- Object
- Kreuzberg::Errors::PanicContext
- Defined in:
- lib/kreuzberg/errors.rb
Instance Attribute Summary collapse
-
#file ⇒ Object
readonly
Returns the value of attribute file.
-
#function ⇒ Object
readonly
Returns the value of attribute function.
-
#line ⇒ Object
readonly
Returns the value of attribute line.
-
#message ⇒ Object
readonly
Returns the value of attribute message.
-
#timestamp_secs ⇒ Object
readonly
Returns the value of attribute timestamp_secs.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(file:, line:, function:, message:, timestamp_secs:) ⇒ PanicContext
constructor
A new instance of PanicContext.
- #to_h ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(file:, line:, function:, message:, timestamp_secs:) ⇒ PanicContext
Returns a new instance of PanicContext.
20 21 22 23 24 25 26 |
# File 'lib/kreuzberg/errors.rb', line 20 def initialize(file:, line:, function:, message:, timestamp_secs:) @file = file @line = line @function = function @message = @timestamp_secs = end |
Instance Attribute Details
#file ⇒ Object (readonly)
Returns the value of attribute file.
18 19 20 |
# File 'lib/kreuzberg/errors.rb', line 18 def file @file end |
#function ⇒ Object (readonly)
Returns the value of attribute function.
18 19 20 |
# File 'lib/kreuzberg/errors.rb', line 18 def function @function end |
#line ⇒ Object (readonly)
Returns the value of attribute line.
18 19 20 |
# File 'lib/kreuzberg/errors.rb', line 18 def line @line end |
#message ⇒ Object (readonly)
Returns the value of attribute message.
18 19 20 |
# File 'lib/kreuzberg/errors.rb', line 18 def @message end |
#timestamp_secs ⇒ Object (readonly)
Returns the value of attribute timestamp_secs.
18 19 20 |
# File 'lib/kreuzberg/errors.rb', line 18 def @timestamp_secs end |
Class Method Details
.from_json(json_string) ⇒ Object
42 43 44 45 46 47 48 49 50 |
# File 'lib/kreuzberg/errors.rb', line 42 def self.from_json(json_string) return nil if json_string.nil? || json_string.empty? data = JSON.parse(json_string, symbolize_names: true) sliced = data.slice(:file, :line, :function, :message, :timestamp_secs) new(**with_defaults(sliced)) rescue JSON::ParserError nil end |
Instance Method Details
#to_h ⇒ Object
32 33 34 35 36 37 38 39 40 |
# File 'lib/kreuzberg/errors.rb', line 32 def to_h { file:, line:, function:, message:, timestamp_secs: } end |
#to_s ⇒ Object
28 29 30 |
# File 'lib/kreuzberg/errors.rb', line 28 def to_s "#{file}:#{line}:#{function}: #{}" end |