Exception: Moxml::XPathError

Inherits:
Error
  • Object
show all
Defined in:
lib/moxml/error.rb

Overview

Error raised when XPath expression evaluation fails

Direct Known Subclasses

Moxml::XPath::Error

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(message, expression: nil, adapter: nil, node: nil) ⇒ XPathError

Returns a new instance of XPathError.



32
33
34
35
36
37
# File 'lib/moxml/error.rb', line 32

def initialize(message, expression: nil, adapter: nil, node: nil)
  @expression = expression
  @adapter = adapter
  @node = node
  super(message)
end

Instance Attribute Details

#adapterObject (readonly)

Returns the value of attribute adapter.



30
31
32
# File 'lib/moxml/error.rb', line 30

def adapter
  @adapter
end

#expressionObject (readonly)

Returns the value of attribute expression.



30
31
32
# File 'lib/moxml/error.rb', line 30

def expression
  @expression
end

#nodeObject (readonly)

Returns the value of attribute node.



30
31
32
# File 'lib/moxml/error.rb', line 30

def node
  @node
end

Instance Method Details

#to_sObject



39
40
41
42
43
44
45
46
# File 'lib/moxml/error.rb', line 39

def to_s
  msg = super
  msg += "\n  Expression: #{@expression}" if @expression
  msg += "\n  Adapter: #{@adapter}" if @adapter
  msg += "\n  Node: <#{@node.name}>" if @node.is_a?(Element) || @node.is_a?(Attribute)
  msg += "\n  Hint: Verify XPath syntax and ensure the adapter supports the expression"
  msg
end