Exception: LintTrappings::ParseError

Inherits:
LintTrappingsError show all
Defined in:
lib/lint_trappings/errors.rb

Overview

Raised when there was a problem parsing a document.

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from LintTrappingsError

exit_status, #exit_status

Constructor Details

#initialize(options) ⇒ ParseError

Returns a new instance of ParseError.



110
111
112
113
114
115
116
117
118
# File 'lib/lint_trappings/errors.rb', line 110

def initialize(options)
  @message = options[:message]
  @path = options[:path]

  if @source_range = options[:source_range]
    @line = @source_range.begin.line
    @column = @source_range.begin.column
  end
end

Instance Attribute Details

#pathString (readonly)

Returns path to the file that failed to parse.

Returns:

  • (String)

    path to the file that failed to parse



105
106
107
# File 'lib/lint_trappings/errors.rb', line 105

def path
  @path
end

#source_rangeRange<LintTrappings::Location> (readonly)

Returns source range of the parse error.

Returns:



108
109
110
# File 'lib/lint_trappings/errors.rb', line 108

def source_range
  @source_range
end

Instance Method Details

#messageObject



120
121
122
123
124
125
# File 'lib/lint_trappings/errors.rb', line 120

def message
  msg = @message
  msg << " on line #{@line}" if @line
  msg << ", column #{@column}" if @column
  msg
end