Class: Kumi::Core::ErrorReporter::ErrorEntry
- Inherits:
-
Object
- Object
- Kumi::Core::ErrorReporter::ErrorEntry
- Defined in:
- lib/kumi/core/error_reporter.rb
Overview
Standard error structure for internal use Provides clean access to location components (file, line, column)
Instance Attribute Summary collapse
-
#backtrace ⇒ Object
readonly
Returns the value of attribute backtrace.
-
#context ⇒ Object
readonly
Returns the value of attribute context.
-
#location ⇒ Object
readonly
Returns the value of attribute location.
-
#message ⇒ Object
readonly
Returns the value of attribute message.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
- #column ⇒ Object
-
#file ⇒ Object
Extract location components cleanly.
-
#initialize(location:, message:, type: :semantic, context: {}, backtrace: nil) ⇒ ErrorEntry
constructor
A new instance of ErrorEntry.
- #line ⇒ Object
-
#location? ⇒ Boolean
Check if location information is present.
-
#path ⇒ Object
Alias for consistency.
- #to_s ⇒ Object
-
#valid_location? ⇒ Boolean
Check if location is valid (has file and line).
Constructor Details
#initialize(location:, message:, type: :semantic, context: {}, backtrace: nil) ⇒ ErrorEntry
Returns a new instance of ErrorEntry.
19 20 21 22 23 24 25 |
# File 'lib/kumi/core/error_reporter.rb', line 19 def initialize(location:, message:, type: :semantic, context: {}, backtrace: nil) @location = location = @type = type @context = context @backtrace = backtrace end |
Instance Attribute Details
#backtrace ⇒ Object (readonly)
Returns the value of attribute backtrace.
17 18 19 |
# File 'lib/kumi/core/error_reporter.rb', line 17 def backtrace @backtrace end |
#context ⇒ Object (readonly)
Returns the value of attribute context.
17 18 19 |
# File 'lib/kumi/core/error_reporter.rb', line 17 def context @context end |
#location ⇒ Object (readonly)
Returns the value of attribute location.
17 18 19 |
# File 'lib/kumi/core/error_reporter.rb', line 17 def location @location end |
#message ⇒ Object (readonly)
Returns the value of attribute message.
17 18 19 |
# File 'lib/kumi/core/error_reporter.rb', line 17 def end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
17 18 19 |
# File 'lib/kumi/core/error_reporter.rb', line 17 def type @type end |
Instance Method Details
#column ⇒ Object
46 47 48 |
# File 'lib/kumi/core/error_reporter.rb', line 46 def column location.is_a?(Syntax::Location) ? location.column : nil end |
#file ⇒ Object
Extract location components cleanly
38 39 40 |
# File 'lib/kumi/core/error_reporter.rb', line 38 def file location.is_a?(Syntax::Location) ? location.file : nil end |
#line ⇒ Object
42 43 44 |
# File 'lib/kumi/core/error_reporter.rb', line 42 def line location.is_a?(Syntax::Location) ? location.line : nil end |
#location? ⇒ Boolean
Check if location information is present
33 34 35 |
# File 'lib/kumi/core/error_reporter.rb', line 33 def location? location && !location.is_a?(Symbol) end |
#path ⇒ Object
Alias for consistency
51 52 53 |
# File 'lib/kumi/core/error_reporter.rb', line 51 def path file end |
#to_s ⇒ Object
27 28 29 30 |
# File 'lib/kumi/core/error_reporter.rb', line 27 def to_s location_str = format_location(location) "#{location_str}: #{message}" end |
#valid_location? ⇒ Boolean
Check if location is valid (has file and line)
56 57 58 |
# File 'lib/kumi/core/error_reporter.rb', line 56 def valid_location? !!(location? && file && line && line > 0) end |