Skip to content

Commit

Permalink
Make error handling work on older versions of libxml_ruby. Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Charlie Savage committed Feb 17, 2013
1 parent 4b3a644 commit c7528b2
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions lib/libxml/error.rb
Expand Up @@ -3,20 +3,24 @@
module LibXML module LibXML
module XML module XML
class Error class Error

# Create mapping from domain constant value to keys
DOMAIN_CODE_MAP =Hash.new.tap do |map| DOMAIN_CODE_MAP = [:NO_ERROR, :PARSER, :TREE, :NAMESPACE, :DTD, :HTML, :MEMORY,
([:NO_ERROR, :PARSER, :TREE, :NAMESPACE, :DTD, :HTML, :MEMORY, :OUTPUT, :IO, :FTP, :HTTP, :XINCLUDE, :XPATH, :XPOINTER, :REGEXP, :DATATYPE, :SCHEMASP, :SCHEMASV, :RELAXNGP, :RELAXNGV, :CATALOG, :C14N, :XSLT, :VALID, :CHECK, :WRITER, :MODULE, :I18N, :SCHEMATRONV] :OUTPUT, :IO, :FTP, :HTTP, :XINCLUDE, :XPATH, :XPOINTER, :REGEXP,
).each do |code| :DATATYPE, :SCHEMASP, :SCHEMASV, :RELAXNGP, :RELAXNGV, :CATALOG,
map[const_get(code)] = code.to_s.gsub(/XML_ERR_/, '') :C14N, :XSLT, :VALID, :CHECK, :WRITER, :MODULE, :I18N, :SCHEMATRONV].inject(Hash.new) do |hash, code|
if const_defined?(code)
hash[const_get(code)] = code.to_s
end end
hash
end end


# Create mapping from domain constant value to keys
ERROR_CODE_MAP = Hash.new.tap do |map| ERROR_CODE_MAP = Hash.new.tap do |map|
(constants - (constants -
DOMAIN_CODE_MAP.values - #Domains DOMAIN_CODE_MAP.values - #Domains
[:NONE, :WARNING, :ERROR, :FATAL] # Levels [:NONE, :WARNING, :ERROR, :FATAL] # Levels
).each do |code| ).each do |code|
map[const_get(code)] = code.to_s.gsub(/XML_ERR_/, '') map[const_get(code)] = code.to_s
end end
end end


Expand Down

0 comments on commit c7528b2

Please sign in to comment.