I'm having some issues with clojure.data.xml in that when parsing bad XML, the exception thrown is not caught. I've found some issues perhaps with run-time wrappers, but my attempts to unwrap it have been unsuccessful can anyone point out to me why this may be happening?
(defn parse-xml-from-string
"takes in valid xml as a string and turns it into
#clojure.data.xml data, if bad xml returns false"
[xml]
(try
(do (parse (java.io.StringReader. xml)))
(catch javax.xml.stream.XMLStreamException e false)
(catch Exception ex
(cond (isa? (class (.getCause ex)) javax.xml.stream.XMLStreamException) false))))
method call
(viva-api.helpers.validation/parse-xml-from-string "<?xml version=\"1.0\"encoding=\"UTF-8\"?><foo><bar><baz>The baz value</baz></bar></foos>")
output
#clojure.data.xml.Element{:tag :foo, :attrs {}, :content (user=> XMLStreamException ParseError at [row,col]:[1,84]
Message: The end-tag for element type "foo" must end with a '>' delimiter. com.sun.org.apache.xerces.internal.impl.XMLStreamReaderImpl.next (XMLStreamReaderImpl.java:598)