Class: Prism::ParseError

Inherits:
Object show all
Defined in:
lib/prism/parse_result.rb

Overview

This represents an error that was encountered during parsing.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(message, location, level) ⇒ ParseError

Create a new error object with the given message and location.



319
320
321
322
323
# File 'lib/prism/parse_result.rb', line 319

def initialize(message, location, level)
  @message = message
  @location = location
  @level = level
end

Instance Attribute Details

#levelObject (readonly)

The level of this error.



316
317
318
# File 'lib/prism/parse_result.rb', line 316

def level
  @level
end

#locationObject (readonly)

A Location object representing the location of this error in the source.



313
314
315
# File 'lib/prism/parse_result.rb', line 313

def location
  @location
end

#messageObject (readonly)

The message associated with this error.



310
311
312
# File 'lib/prism/parse_result.rb', line 310

def message
  @message
end

Instance Method Details

#deconstruct_keys(keys) ⇒ Object

Implement the hash pattern matching interface for ParseError.



326
327
328
# File 'lib/prism/parse_result.rb', line 326

def deconstruct_keys(keys)
  { message: message, location: location, level: level }
end

#inspectObject

Returns a string representation of this error.



331
332
333
# File 'lib/prism/parse_result.rb', line 331

def inspect
  "#<Prism::ParseError @message=#{@message.inspect} @location=#{@location.inspect} @level=#{@level.inspect}>"
end