Exception: HRX::ParseError

Inherits:
Error
  • Object
show all
Defined in:
lib/hrx/parse_error.rb

Overview

An error caused by an HRX file failing to parse correctly.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(message, line, column, file: nil) ⇒ ParseError

Returns a new instance of ParseError.



28
29
30
31
32
33
# File 'lib/hrx/parse_error.rb', line 28

def initialize(message, line, column, file: nil)
  super(message)
  @line = line
  @column = column
  @file = file
end

Instance Attribute Details

#columnObject (readonly)

The 1-based column of the line on which the error occurred.



23
24
25
# File 'lib/hrx/parse_error.rb', line 23

def column
  @column
end

#fileObject (readonly)

The file which failed to parse, or ‘nil` if the filename isn’t known.



26
27
28
# File 'lib/hrx/parse_error.rb', line 26

def file
  @file
end

#lineObject (readonly)

The 1-based line of the document on which the error occurred.



20
21
22
# File 'lib/hrx/parse_error.rb', line 20

def line
  @line
end

Instance Method Details

#to_sObject



35
36
37
38
39
# File 'lib/hrx/parse_error.rb', line 35

def to_s
  buffer = String.new("Parse error on line #{line}, column #{column}")
  buffer << " of #{file}" if file
  buffer << ": #{super.to_s}"
end