Exception: DataMetaParse::Err
- Inherits:
-
RuntimeError
- Object
- RuntimeError
- DataMetaParse::Err
- Defined in:
- lib/dataMetaParse.rb
Overview
Parsing error, RuntimeError augmented with report feature
Instance Attribute Summary collapse
-
#parser ⇒ Object
readonly
Returns the value of attribute parser.
-
#source ⇒ Object
readonly
Returns the value of attribute source.
Instance Method Summary collapse
-
#initialize(source, parser) ⇒ Err
constructor
Constructor, constructs also the error message passed to the super.
Constructor Details
#initialize(source, parser) ⇒ Err
Constructor, constructs also the error message passed to the super.
25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/dataMetaParse.rb', line 25 def initialize(source, parser) @source, @parser = source, parser parser.failure_reason =~ /^(Expected .+) after/m reason = $1 || 'REASONLESS' # replace newlines with <EOL> to make them stand out super %Q<ERROR at index #{parser.index} #{reason.gsub("\n", '<EOL>')}: #{source.lines.to_a[parser.failure_line - 1]} #{'~' * (parser.failure_column - 1)}^ > end |
Instance Attribute Details
#parser ⇒ Object (readonly)
Returns the value of attribute parser.
18 19 20 |
# File 'lib/dataMetaParse.rb', line 18 def parser @parser end |
#source ⇒ Object (readonly)
Returns the value of attribute source.
18 19 20 |
# File 'lib/dataMetaParse.rb', line 18 def source @source end |