I want to know which kind of exceptions can be thrown by this code so i can catch them instead of just catching the generic exception (trying to reproduce errors to cause exception is difficult here cause it takes a lot of time to set up the request used )
JAXBContext jc = JAXBContext.newInstance(QueryReport.class);
Marshaller marshaller = jc.createMarshaller();
marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.valueOf(true));
marshaller.marshal(requestService, out);
is = new ByteArrayInputStream(out.toByteArray());
JAXBReader jcReader = new JAXBReader("QueryReport");
log.debug("\n# XML QueryRequest Response: " + jcReader.read(is).asXML());
so if anyone has an idea of which exceptions maybe thrown here.
Thanks
From the code block you’ve shown, the possible exeception will be JAXBException from calling
JAXBContextand ClassNotFoundException ifQueryReport.classcannot be located from the classpath and IOException if call toByteArrayInputStreamfailed.You can use your IDE to wrap the relevant portion of code with generated try/catch block, with the Exception it see fit for the syntax block.