Exception: Eeml::Exceptions::MissingNode

Inherits:
BadEeml show all
Defined in:
lib/eeml/exceptions.rb

Overview

A structured exception which holds info about what was missing and from where. Note: Some reasons we don’t just hold everything in an unstructured exception message:

  1. some bits might be useful for dev but not for the public,

  2. testing is simplified by having the missing node name recorded explicitly (rather than in a human-readable, changeable string).

Instance Attribute Summary collapse

Attributes inherited from BadEeml

#line_num, #node_name

Instance Method Summary collapse

Constructor Details

#initialize(base_node_name, sought_description, sought_xpath = nil) ⇒ MissingNode



36
37
38
39
40
# File 'lib/eeml/exceptions.rb', line 36

def initialize(base_node_name, sought_description, sought_xpath = nil)
  @base_node_name = base_node_name
  @sought_description = sought_description
  @sought_xpath = sought_xpath
end

Instance Attribute Details

#base_node_nameObject

Returns the value of attribute base_node_name.



34
35
36
# File 'lib/eeml/exceptions.rb', line 34

def base_node_name
  @base_node_name
end

#sought_descriptionObject

Returns the value of attribute sought_description.



34
35
36
# File 'lib/eeml/exceptions.rb', line 34

def sought_description
  @sought_description
end

#sought_xpathObject

Returns the value of attribute sought_xpath.



34
35
36
# File 'lib/eeml/exceptions.rb', line 34

def sought_xpath
  @sought_xpath
end

Instance Method Details

#to_sObject



42
43
44
45
# File 'lib/eeml/exceptions.rb', line 42

def to_s
  "Missing '#@sought_description' node from base node: '#@base_node_name'" +
  (@sought_xpath ? "with xpath: '#@sought_xpath'" : "")
end