/** * If the exception was caused by an {@link IOException}, wrap it an another IOE so * that it will be exposed to the RetryPolicy. */ private Exception handleXmlStreamException(XMLStreamException e) throws Exception { if (e.getNestedException() instanceof IOException) { return new IOException(e); } return e; }
private static JAXBException handleStreamException(XMLStreamException e) { // StAXStreamConnector wraps SAXException to XMLStreamException. // XMLStreamException doesn't print its nested stack trace when it prints // its stack trace, so if we wrap XMLStreamException in JAXBException, // it becomes harder to find out the real problem. // So we unwrap them here. But we don't want to unwrap too eagerly, because // that could throw away some meaningful exception information. Throwable ne = e.getNestedException(); if(ne instanceof JAXBException) { return (JAXBException)ne; } if(ne instanceof SAXException) { return new UnmarshalException(ne); } return new UnmarshalException(e); }
/** * If the exception was caused by an {@link IOException}, wrap it an another IOE so * that it will be exposed to the RetryPolicy. */ private Exception handleXmlStreamException(XMLStreamException e) throws Exception { if (e.getNestedException() instanceof IOException) { return new IOException(e); } return e; }
private static JAXBException handleStreamException(XMLStreamException e) { // StAXStreamConnector wraps SAXException to XMLStreamException. // XMLStreamException doesn't print its nested stack trace when it prints // its stack trace, so if we wrap XMLStreamException in JAXBException, // it becomes harder to find out the real problem. // So we unwrap them here. But we don't want to unwrap too eagerly, because // that could throw away some meaningful exception information. Throwable ne = e.getNestedException(); if(ne instanceof JAXBException) { return (JAXBException)ne; } if(ne instanceof SAXException) { return new UnmarshalException(ne); } return new UnmarshalException(e); }
/** * If the exception was caused by an {@link IOException}, wrap it an another IOE so * that it will be exposed to the RetryPolicy. */ private Exception handleXmlStreamException(XMLStreamException e) throws Exception { if (e.getNestedException() instanceof IOException) { return new IOException(e); } return e; }
protected void throwUnchecked(XMLStreamException sex) { // Wrapped root cause? Let's only unwrap one layer; one that // must have been used to expose the problem (if any) Throwable t = (sex.getNestedException() == null) ? sex : sex.getNestedException(); // Unchecked? Can re-throw as is if (t instanceof RuntimeException) { throw (RuntimeException) t; } if (t instanceof Error) { throw (Error) t; } // Otherwise, let's just wrap it throw new RuntimeException("[was "+t.getClass()+"] "+t.getMessage(), t); }
protected void throwUnchecked(XMLStreamException sex) { // Wrapped root cause? Let's only unwrap one layer; one that // must have been used to expose the problem (if any) Throwable t = (sex.getNestedException() == null) ? sex : sex.getNestedException(); // Unchecked? Can re-throw as is if (t instanceof RuntimeException) { throw (RuntimeException) t; } if (t instanceof Error) { throw (Error) t; } // Otherwise, let's just wrap it throw new RuntimeException("[was "+t.getClass()+"] "+t.getMessage(), t); }
protected void throwUnchecked(XMLStreamException sex) { /* Wrapped root cause? Let's only unwrap one layer; one that * must have been used to expose the problem (if any) */ Throwable t = (sex.getNestedException() == null) ? sex : sex.getNestedException(); // Unchecked? Can re-throw as is if (t instanceof RuntimeException) { throw (RuntimeException) t; } if (t instanceof Error) { throw (Error) t; } // Otherwise, let's just wrap it throw new RuntimeException("[was "+t.getClass()+"] "+t.getMessage(), t); }
@Override public void writeXmlConfiguration(final OutputStream output) throws IOException { try { final XMLStreamWriter xmlWriter = XMLOutputFactory.newInstance().createXMLStreamWriter(output); writeXmlConfiguration(xmlWriter); xmlWriter.close(); } catch (final XMLStreamException e) { if (e.getNestedException() instanceof IOException) { throw (IOException)e.getNestedException(); } Throwables.rethrow(e); } }
private static JAXBException handleStreamException(XMLStreamException e) { // StAXStreamConnector wraps SAXException to XMLStreamException. // XMLStreamException doesn't print its nested stack trace when it prints // its stack trace, so if we wrap XMLStreamException in JAXBException, // it becomes harder to find out the real problem. // So we unwrap them here. But we don't want to unwrap too eagerly, because // that could throw away some meaningful exception information. Throwable ne = e.getNestedException(); if(ne instanceof JAXBException) { return (JAXBException)ne; } if(ne instanceof SAXException) { return new UnmarshalException(ne); } return new UnmarshalException(e); }
private static JAXBException handleStreamException(XMLStreamException e) { // StAXStreamConnector wraps SAXException to XMLStreamException. // XMLStreamException doesn't print its nested stack trace when it prints // its stack trace, so if we wrap XMLStreamException in JAXBException, // it becomes harder to find out the real problem. // So we unwrap them here. But we don't want to unwrap too eagerly, because // that could throw away some meaningful exception information. Throwable ne = e.getNestedException(); if(ne instanceof JAXBException) { return (JAXBException)ne; } if(ne instanceof SAXException) { return new UnmarshalException(ne); } return new UnmarshalException(e); }
public AbstractXSLTInterceptor(String phase, Class<?> before, Class<?> after, String xsltPath) { super(phase); if (before != null) { addBefore(before.getName()); } if (after != null) { addAfter(after.getName()); } try { InputStream xsltStream = ClassLoaderUtils.getResourceAsStream(xsltPath, this.getClass()); if (xsltStream == null) { throw new IllegalArgumentException("Cannot load XSLT from path: " + xsltPath); } Document doc = StaxUtils.read(xsltStream); xsltTemplate = TRANSFORM_FACTORIY.newTemplates(new DOMSource(doc)); } catch (TransformerConfigurationException e) { throw new IllegalArgumentException( String.format("Cannot create XSLT template from path: %s, error: ", xsltPath, e.getException()), e); } catch (XMLStreamException e) { throw new IllegalArgumentException( String.format("Cannot create XSLT template from path: %s, error: ", xsltPath, e.getNestedException()), e); } }
public AbstractXSLTInterceptor(String phase, Class<?> before, Class<?> after, String xsltPath) { super(phase); if (before != null) { addBefore(before.getName()); } if (after != null) { addAfter(after.getName()); } try { InputStream xsltStream = ClassLoaderUtils.getResourceAsStream(xsltPath, this.getClass()); if (xsltStream == null) { throw new IllegalArgumentException("Cannot load XSLT from path: " + xsltPath); } Document doc = StaxUtils.read(xsltStream); xsltTemplate = TRANSFORM_FACTORIY.newTemplates(new DOMSource(doc)); } catch (TransformerConfigurationException e) { throw new IllegalArgumentException( String.format("Cannot create XSLT template from path: %s, error: ", xsltPath, e.getException()), e); } catch (XMLStreamException e) { throw new IllegalArgumentException( String.format("Cannot create XSLT template from path: %s, error: ", xsltPath, e.getNestedException()), e); } }
public static String extractFaultCode(Throwable throwable) { if (throwable instanceof DataServiceFault) { return ((DataServiceFault) throwable).getCode(); } else if (throwable instanceof XMLStreamException) { return extractFaultCode(((XMLStreamException) throwable).getNestedException()); } else if (throwable != null) { Throwable cause = throwable.getCause(); if (cause != null) { return extractFaultCode(cause); } else { return FaultCodes.UNKNOWN_ERROR; } } else { return FaultCodes.UNKNOWN_ERROR; } }
if (throwable instanceof DataServiceFault) { if (throwable.getCause() instanceof XMLStreamException) { return extractFaultMessage(((XMLStreamException) throwable.getCause()).getNestedException()); return extractFaultMessage(((XMLStreamException) throwable).getNestedException()); } else if (throwable != null) { Throwable cause = throwable.getCause();
if (!reported) { if (e instanceof XMLStreamValidationException) { cause = e.getNestedException(); } else { cause = e;
if (!reported) { if (e instanceof XMLStreamValidationException) { cause = e.getNestedException(); } else { cause = e;
throw new IllegalArgumentException( String.format("Cannot create XSLT template from path: %s, error: ", xsltPath, e.getNestedException()), e); } finally {
Throwable t = e.getNestedException(); if (t instanceof IOException) { exception = (IOException) t;