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

  • #level readonly

    The level of this error.

  • #location readonly

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

  • #message readonly

    The message associated with this error.

  • #type readonly

    The type of error.

Instance Method Summary

Constructor Details

.new(type, message, location, level) ⇒ ParseError

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

[ GitHub ]

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

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

Instance Attribute Details

#level (readonly)

The level of this error.

[ GitHub ]

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

attr_reader :level

#location (readonly)

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

[ GitHub ]

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

attr_reader :location

#message (readonly)

The message associated with this error.

[ GitHub ]

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

attr_reader :message

#type (readonly)

The type of error. This is an internal symbol that is used for communicating with translation layers. It is not meant to be public API.

[ GitHub ]

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

attr_reader :type

Instance Method Details

#deconstruct_keys(keys)

Implement the hash pattern matching interface for ParseError.

[ GitHub ]

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

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

#inspect

Returns a string representation of this error.

[ GitHub ]

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

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