Skip to content

Commit 26b62fd

Browse files
committed
Comment back in error tests and fix incorrect error code mapping.
1 parent bc968af commit 26b62fd

2 files changed

Lines changed: 201 additions & 185 deletions

File tree

lib/libxml/error.rb

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,24 +3,24 @@
33
module LibXML
44
module XML
55
class Error
6-
# Create mapping from domain constant value to keys
6+
# Create mapping from domain constant values to keys
77
DOMAIN_CODE_MAP = [:NO_ERROR, :PARSER, :TREE, :NAMESPACE, :DTD, :HTML, :MEMORY,
88
:OUTPUT, :IO, :FTP, :HTTP, :XINCLUDE, :XPATH, :XPOINTER, :REGEXP,
99
:DATATYPE, :SCHEMASP, :SCHEMASV, :RELAXNGP, :RELAXNGV, :CATALOG,
1010
:C14N, :XSLT, :VALID, :CHECK, :WRITER, :MODULE, :I18N, :SCHEMATRONV].inject(Hash.new) do |hash, code|
1111
if const_defined?(code)
12-
hash[const_get(code)] = code.to_s
12+
hash[const_get(code)] = code
1313
end
1414
hash
1515
end
1616

17-
# Create mapping from domain constant value to keys
17+
# Create mapping from error constant values (so need to remove domain_codes) to keys
1818
ERROR_CODE_MAP = Hash.new.tap do |map|
1919
(constants -
2020
DOMAIN_CODE_MAP.values - #Domains
2121
[:NONE, :WARNING, :ERROR, :FATAL] # Levels
2222
).each do |code|
23-
map[const_get(code)] = code.to_s
23+
map[const_get(code)] = code
2424
end
2525
end
2626

@@ -70,11 +70,11 @@ def level_to_s
7070
end
7171

7272
def domain_to_s
73-
DOMAIN_CODE_MAP[self.domain]
73+
DOMAIN_CODE_MAP[self.domain].to_s
7474
end
7575

7676
def code_to_s
77-
ERROR_CODE_MAP[self.code]
77+
ERROR_CODE_MAP[self.code].to_s
7878
end
7979

8080
def to_s
@@ -92,4 +92,4 @@ def to_s
9292
end
9393
end
9494

95-
LibXML::XML::Error.set_handler(&LibXML::XML::Error::VERBOSE_HANDLER)
95+
LibXML::XML::Error.set_handler(&LibXML::XML::Error::VERBOSE_HANDLER)

0 commit comments

Comments
 (0)