123456789_123456789_123456789_123456789_123456789_

Class: Prism::ParseError

Relationships & Source Files
Inherits: Object
Defined in: lib/prism/parse_result.rb,
prism/extension.c

Overview

This represents an error that was encountered during parsing.

Class Method Summary

Instance Attribute Summary

  • #location readonly

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

  • #message readonly

    The message associated with this error.

Instance Method Summary

Constructor Details

.new(message, location) ⇒ ParseError

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

[ GitHub ]

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

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

Instance Attribute Details

#location (readonly)

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

[ GitHub ]

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

attr_reader :location

#message (readonly)

The message associated with this error.

[ GitHub ]

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

attr_reader :message

Instance Method Details

#deconstruct_keys(keys)

Implement the hash pattern matching interface for ParseError.

[ GitHub ]

  
# File 'lib/prism/parse_result.rb', line 322

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

#inspect

Returns a string representation of this error.

[ GitHub ]

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

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