Example usage for org.springframework.oxm UncategorizedMappingException UncategorizedMappingException

List of usage examples for org.springframework.oxm UncategorizedMappingException UncategorizedMappingException

Introduction

In this page you can find the example usage for org.springframework.oxm UncategorizedMappingException UncategorizedMappingException.

Prototype

public UncategorizedMappingException(String msg, Throwable cause) 

Source Link

Document

Construct an UncategorizedMappingException with the specified detail message and nested exception.

Usage

From source file:org.springframework.oxm.jaxb.Jaxb2Marshaller.java

/**
 * Convert the given {@code JAXBException} to an appropriate exception from the
 * {@code org.springframework.oxm} hierarchy.
 * @param ex {@code JAXBException} that occurred
 * @return the corresponding {@code XmlMappingException}
 *//*from   w w w  . j a  v  a  2 s .c  om*/
protected XmlMappingException convertJaxbException(JAXBException ex) {
    if (ex instanceof ValidationException) {
        return new ValidationFailureException("JAXB validation exception", ex);
    } else if (ex instanceof MarshalException) {
        return new MarshallingFailureException("JAXB marshalling exception", ex);
    } else if (ex instanceof UnmarshalException) {
        return new UnmarshallingFailureException("JAXB unmarshalling exception", ex);
    } else {
        // fallback
        return new UncategorizedMappingException("Unknown JAXB exception", ex);
    }
}

From source file:org.springframework.oxm.xmlbeans.XmlBeansMarshaller.java

/**
 * Convert the given XMLBeans exception to an appropriate exception from the
 * <code>org.springframework.oxm</code> hierarchy.
 * <p>A boolean flag is used to indicate whether this exception occurs during marshalling or
 * unmarshalling, since XMLBeans itself does not make this distinction in its exception hierarchy.
 * @param ex XMLBeans Exception that occured
 * @param marshalling indicates whether the exception occurs during marshalling (<code>true</code>),
 * or unmarshalling (<code>false</code>)
 * @return the corresponding <code>XmlMappingException</code>
 *//*  w  w  w.j a  v  a  2s .co m*/
protected XmlMappingException convertXmlBeansException(Exception ex, boolean marshalling) {
    if (ex instanceof XMLStreamValidationException) {
        return new ValidationFailureException("XmlBeans validation exception", ex);
    } else if (ex instanceof XmlException || ex instanceof SAXException) {
        if (marshalling) {
            return new MarshallingFailureException("XMLBeans marshalling exception", ex);
        } else {
            return new UnmarshallingFailureException("XMLBeans unmarshalling exception", ex);
        }
    } else {
        // fallback
        return new UncategorizedMappingException("Unknown XMLBeans exception", ex);
    }
}