Exception: LD::Patch::ParseError

Inherits:
Error
  • Object
show all
Defined in:
lib/ld/patch.rb

Overview

Indicates bad syntax found in LD Patch document

Instance Attribute Summary collapse

Attributes inherited from Error

#code

Instance Method Summary collapse

Constructor Details

#initialize(message, options = {}) ⇒ ParseError

Initializes a new parser error instance.

Parameters:

  • message (String, #to_s)
  • options (Hash{Symbol => Object}) (defaults to: {})

Options Hash (options):

  • :token (String) — default: nil
  • :lineno (Integer) — default: nil
  • :code (Integer) — default: 400


72
73
74
75
76
# File 'lib/ld/patch.rb', line 72

def initialize(message, options = {})
  @token      = options[:token]
  @lineno     = options[:lineno] || (@token.lineno if @token.respond_to?(:lineno))
  super(message.to_s, code: options.fetch(:code, 400))
end

Instance Attribute Details

#linenoInteger (readonly)

The line number where the error occurred.

Returns:

  • (Integer)


62
63
64
# File 'lib/ld/patch.rb', line 62

def lineno
  @lineno
end

#tokenString (readonly)

The invalid token which triggered the error.

Returns:

  • (String)


56
57
58
# File 'lib/ld/patch.rb', line 56

def token
  @token
end