Exception: XRB::ParseError
Overview
Raised when an XRB parser encounters invalid input.
Instance Attribute Summary collapse
-
#buffer ⇒ Object
readonly
Returns the value of attribute buffer.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Instance Method Summary collapse
-
#initialize(message, buffer, offset) ⇒ ParseError
constructor
Initialize a parse error at a specific byte offset within a buffer.
-
#location ⇒ Object
Compute the location of the parse error within the input buffer.
-
#to_s ⇒ Object
Format the error with its path, location, message, and source line.
Constructor Details
#initialize(message, buffer, offset) ⇒ ParseError
Initialize a parse error at a specific byte offset within a buffer.
19 20 21 22 23 24 |
# File 'lib/xrb/error.rb', line 19 def initialize(, buffer, offset) super() @buffer = buffer @offset = offset end |
Instance Attribute Details
#buffer ⇒ Object (readonly)
Returns the value of attribute buffer.
32 33 34 |
# File 'lib/xrb/error.rb', line 32 def buffer @buffer end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
33 34 35 |
# File 'lib/xrb/error.rb', line 33 def path @path end |
Instance Method Details
#location ⇒ Object
Compute the location of the parse error within the input buffer.
28 29 30 |
# File 'lib/xrb/error.rb', line 28 def location @location ||= Location.new(@buffer.read, @offset) end |
#to_s ⇒ Object
Format the error with its path, location, message, and source line.
37 38 39 |
# File 'lib/xrb/error.rb', line 37 def to_s "#{buffer.path}#{location}: #{super}\n#{location.line_text}" end |