Sha256: c983b27f20902750fa9b63fdae7deaaa878596b44be6ed663dc146d70811d551
Contents?: true
Size: 1.95 KB
Versions: 1
Compression:
Stored size: 1.95 KB
Contents
module Eeml # exceptions #TODO: have these inherit from a base parser error class Unavailable < StandardError; end class BadResponse < StandardError; end class ApiKeyMissing < StandardError; end class AuthenticationFailure < StandardError; end class BadEeml < StandardError #eeml being parsed was ok xml but bad eeml attr_accessor :line_num, :node_name #no guarantees either is available def to_s extras = [] extras << " node name: '" + node_name + "'" if node_name extras << " line_num: #{line_num}" if line_num super.to_s + extras.join(',') end end class BadXML < StandardError; end #xml being parsed was malformed class DataMissingValue < BadEeml; end class DataHasMultipleUnits < BadEeml; end class DataHasMultipleValues < BadEeml; end class NoDataStreams < BadEeml; end #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). class MissingNode < BadEeml attr_accessor :base_node_name, :sought_description, :sought_xpath 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 def to_s "Missing '#@sought_description' node from base node: '#@base_node_name'" + (@sought_xpath ? "with xpath: '#@sought_xpath'" : "") end end class MissingAttribute < BadEeml attr_accessor :node_name, :attribute_name def initialize(node_name, attribute_name) @node_name = node_name @attribute_name = attribute_name end def to_s "Missing attribute '#@attribute_name' from node '#@node_name'" end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
eeml-0.0.1 | lib/eeml/exceptions.rb |