if (e instanceof XMLStreamException) {
final Throwable cause = e.getCause();
if (cause instanceof JAXBException) {
throw (JAXBException) e;
}
throw new MarshalException(cause == null ? e : cause);
}
throw new MarshalException(e);
}
w.writeEndDocument();
} catch (final Exception e) {
throw new MarshalException(e);
}
} catch (final XMLStreamException e) {
throw new JAXBException("Could not close XMLStreamWriter.", e);