e.getExceptionText().add(sb.toString()); e.getExceptionText().addAll(exception.getExceptionText()); e.getExceptionText().add("Details:"); ByteArrayOutputStream trace = new ByteArrayOutputStream(); exception.printStackTrace(new PrintStream(trace)); e.getExceptionText().add(new String(trace.toByteArray()));
public void testParseServiceException() throws Exception { String xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + "<ows:ExceptionReport version=\"1.0.0\"\n" + " xsi:schemaLocation=\"http://www.opengis.net/ows http://demo.opengeo.org/geoserver/schemas/ows/1.0.0/owsExceptionReport.xsd\"\n" + " xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:ows=\"http://www.opengis.net/ows\">\n" + " <ows:Exception exceptionCode=\"InvalidParameterValue\" locator=\"service\">\n" + " <ows:ExceptionText>No service: ( madeUp )</ows:ExceptionText>\n" + " </ows:Exception>\n" + "</ows:ExceptionReport>\n" + ""; document = dom(xml); Object result = parse(OWS.EXCEPTIONREPORT); assertNotNull(result); assertTrue(result instanceof ExceptionReportType); ExceptionReportType er = (ExceptionReportType) result; assertEquals("1.0.0", er.getVersion()); assertEquals(1, er.getException().size()); ExceptionType ex = (ExceptionType) er.getException().get(0); assertEquals("InvalidParameterValue", ex.getExceptionCode()); assertEquals("service", ex.getLocator()); assertEquals(1, ex.getExceptionText().size()); assertEquals("No service: ( madeUp )", ex.getExceptionText().get(0)); } }
for (net.opengis.ows10.ExceptionType ex : exceptions) { @SuppressWarnings("unchecked") List<String> texts = ex.getExceptionText(); result.addExceptionDetails(ex.getExceptionCode(), ex.getLocator(), texts);
result.addExceptionReport(String.valueOf(ex.getExceptionText()));
for (net.opengis.ows10.ExceptionType ex : exceptions) { @SuppressWarnings("unchecked") List<String> texts = ex.getExceptionText(); result.addExceptionDetails(ex.getExceptionCode(), ex.getLocator(), texts);