Class: Prism::ParseError

Inherits:
Object
  • Object
show all
Defined in:
lib/prism/parse_result.rb,
ext/prism/extension.c

Overview

This represents an error that was encountered during parsing.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(type, message, location, level) ⇒ ParseError

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



624
625
626
627
628
629
# File 'lib/prism/parse_result.rb', line 624

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

Instance Attribute Details

#levelObject (readonly)

The level of this error.



621
622
623
# File 'lib/prism/parse_result.rb', line 621

def level
  @level
end

#locationObject (readonly)

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



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

def location
  @location
end

#messageObject (readonly)

The message associated with this error.



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

def message
  @message
end

#typeObject (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.



612
613
614
# File 'lib/prism/parse_result.rb', line 612

def type
  @type
end

Instance Method Details

#deconstruct_keys(keys) ⇒ Object

Implement the hash pattern matching interface for ParseError.



632
633
634
# File 'lib/prism/parse_result.rb', line 632

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

#inspectObject

Returns a string representation of this error.



637
638
639
# File 'lib/prism/parse_result.rb', line 637

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