The content is a valid XML text.
But XmlSlurper().parseText(content)
produced a java.lang.reflect.UndeclaredThrowableException
Questions:
- is there a possibility to verify the XML to find out, what the problem is?
- How ca I handle this exception in the
catch()
part or how can I get the "original" exception type?
import org.apache.commons.io.IOUtils
import org.codehaus.groovy.runtime.StackTraceUtils
import java.nio.charset.*
import groovy.json.*
import groovy.util.*
def flowFile = session.get()
if (!flowFile) return
try {
flowFile = session.write(flowFile,
{inputStream, outputStream ->
def content = IOUtils.toString(inputStream, StandardCharsets.UTF_8)
def MyCatalog = new XmlSlurper().parseText(content)
} as StreamCallback )
session.transfer(flowFile, REL_SUCCESS)
} catch(Exception e) {
def err = "Error in parseText() ${e}"
log.error(err, e)
session.transfer(flowFile, REL_FAILURE)
}