Java Code Examples for javax.xml.stream.XMLStreamException#getNestedException()
The following examples show how to use
javax.xml.stream.XMLStreamException#getNestedException() .
These examples are extracted from open source projects.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: TencentKona-8 File: UnmarshallerImpl.java License: GNU General Public License v2.0 | 6 votes |
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); }
Example 2
Source Project: jdk8u60 File: UnmarshallerImpl.java License: GNU General Public License v2.0 | 6 votes |
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); }
Example 3
Source Project: openjdk-jdk8u File: UnmarshallerImpl.java License: GNU General Public License v2.0 | 6 votes |
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); }
Example 4
Source Project: openjdk-jdk8u-backup File: UnmarshallerImpl.java License: GNU General Public License v2.0 | 6 votes |
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); }
Example 5
Source Project: openjdk-jdk9 File: UnmarshallerImpl.java License: GNU General Public License v2.0 | 6 votes |
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); }
Example 6
Source Project: hottub File: UnmarshallerImpl.java License: GNU General Public License v2.0 | 6 votes |
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); }
Example 7
Source Project: openjdk-8-source File: UnmarshallerImpl.java License: GNU General Public License v2.0 | 6 votes |
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); }
Example 8
Source Project: openjdk-8 File: UnmarshallerImpl.java License: GNU General Public License v2.0 | 6 votes |
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); }
Example 9
Source Project: datacollector File: OverrunStreamingXmlParser.java License: Apache License 2.0 | 6 votes |
@Override public Field read() throws IOException, XMLStreamException { Field field; Utils.checkState(!overrun, "The underlying input stream had an overrun, the parser is not usable anymore"); countingReader.resetCount(); limit = getReaderPosition() + maxObjectLen; try { field = super.read(); throwIfOverMaxObjectLength(); initialPosition = getReaderPosition(); } catch (XMLStreamException ex) { if (ex.getNestedException() != null && ex.getNestedException() instanceof OverrunException) { overrun = true; throw (OverrunException) ex.getNestedException(); } throw ex; } return field; }
Example 10
Source Project: openjdk-jdk9 File: XMLResolverTest.java License: GNU General Public License v2.0 | 5 votes |
@Test public void testXMLResolver() { try { XMLInputFactory xifactory = XMLInputFactory.newInstance(); xifactory.setProperty(XMLInputFactory.RESOLVER, new MyStaxResolver()); File file = new File(getClass().getResource("XMLResolverTest.xml").getFile()); String systemId = file.toURI().toString(); InputStream entityxml = new FileInputStream(file); XMLStreamReader streamReader = xifactory.createXMLStreamReader(systemId, entityxml); while (streamReader.hasNext()) { int eventType = streamReader.next(); if (eventType == XMLStreamConstants.START_ELEMENT) { eventType = streamReader.next(); if (eventType == XMLStreamConstants.CHARACTERS) { String text = streamReader.getText(); Assert.assertTrue(text.contains("replace2")); } } } } catch (XMLStreamException ex) { if (ex.getNestedException() != null) { ex.getNestedException().printStackTrace(); } // ex.printStackTrace() ; } catch (Exception io) { io.printStackTrace(); } }
Example 11
Source Project: ibm-cos-sdk-java File: StaxResponseHandler.java License: Apache License 2.0 | 5 votes |
/** * 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; }
Example 12
Source Project: logging-log4j2 File: DefaultConfigurationBuilder.java License: Apache License 2.0 | 5 votes |
@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); } }