Exception: Kumi::Core::Errors::LocatedError
- Defined in:
- lib/kumi/core/errors.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#location ⇒ Object
readonly
Returns the value of attribute location.
Instance Method Summary collapse
-
#format_location ⇒ Object
Format location for error messages.
-
#has_location? ⇒ Boolean
Check if location information is present and valid.
-
#initialize(message, location = nil) ⇒ LocatedError
constructor
A new instance of LocatedError.
- #location_column ⇒ Object (also: #column)
-
#location_file ⇒ Object
(also: #path)
Extract location components cleanly.
- #location_line ⇒ Object (also: #line)
- #to_s ⇒ Object
Constructor Details
#initialize(message, location = nil) ⇒ LocatedError
Returns a new instance of LocatedError.
11 12 13 14 |
# File 'lib/kumi/core/errors.rb', line 11 def initialize(, location = nil) super() @location = location end |
Instance Attribute Details
#location ⇒ Object (readonly)
Returns the value of attribute location.
9 10 11 |
# File 'lib/kumi/core/errors.rb', line 9 def location @location end |
Instance Method Details
#format_location ⇒ Object
Format location for error messages
40 41 42 43 44 45 46 |
# File 'lib/kumi/core/errors.rb', line 40 def format_location if @location "at #{@location.file} line=#{@location.line} column=#{@location.column}" else "at ?" end end |
#has_location? ⇒ Boolean
Check if location information is present and valid
35 36 37 |
# File 'lib/kumi/core/errors.rb', line 35 def has_location? @location && @location.file && @location.line && @location.line > 0 end |
#location_column ⇒ Object Also known as: column
25 26 27 |
# File 'lib/kumi/core/errors.rb', line 25 def location_column @location&.column end |
#location_file ⇒ Object Also known as: path
Extract location components cleanly
17 18 19 |
# File 'lib/kumi/core/errors.rb', line 17 def location_file @location&.file end |
#location_line ⇒ Object Also known as: line
21 22 23 |
# File 'lib/kumi/core/errors.rb', line 21 def location_line @location&.line end |
#to_s ⇒ Object
48 49 50 51 52 53 54 |
# File 'lib/kumi/core/errors.rb', line 48 def to_s if @location "#{super} #{format_location}" else super end end |