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})

Options Hash (**options):

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


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

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)


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

def lineno
  @lineno
end

#tokenString (readonly)

The invalid token which triggered the error.

Returns:

  • (String)


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

def token
  @token
end