Exception: LLIP::LLIPError

Inherits:
StandardError
  • Object
show all
Defined in:
lib/llip/llip_error.rb

Overview

It’s the base Exception for all the exception of LLIP. It adds a header to all the messages with the line and the char of the token that caused the exception.

To subclass it for a class-specific message, pass it to the constructor or override the :message method.

Direct Known Subclasses

ParserError, UnvalidTokenError

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(token, msg = nil) ⇒ LLIPError

Returns a new instance of LLIPError.



16
17
18
19
# File 'lib/llip/llip_error.rb', line 16

def initialize(token,msg=nil)
  super msg
  @token = token
end

Instance Attribute Details

#tokenObject (readonly)

The token that caused the exception



14
15
16
# File 'lib/llip/llip_error.rb', line 14

def token
  @token
end

Instance Method Details

#internal_messageObject



21
# File 'lib/llip/llip_error.rb', line 21

alias :internal_message :to_s

#to_sObject



23
24
25
# File 'lib/llip/llip_error.rb', line 23

def to_s
  "At line #{token.line} char #{token.char} a #{self.class.name} occurred: #{internal_message}"
end