Example usage for java.lang.reflect UndeclaredThrowableException getUndeclaredThrowable

List of usage examples for java.lang.reflect UndeclaredThrowableException getUndeclaredThrowable

Introduction

In this page you can find the example usage for java.lang.reflect UndeclaredThrowableException getUndeclaredThrowable.

Prototype

public Throwable getUndeclaredThrowable() 

Source Link

Document

Returns the Throwable instance wrapped in this UndeclaredThrowableException , which may be null .

Usage

From source file:org.uddi.v3_service.DispositionReportFaultMessage.java

/** 
 * Convenience method to figure out if the Exception at hand contains a
 * DispositionReport. Disposition report will be null if none can be found.
 * //ww w. j av a  2  s  .c om
 * @param e the Exception at hang
 * @return DispositionReport if one can be found, or null if it is not.
 */
public static DispositionReport getDispositionReport(Exception e) {
   DispositionReport report = null;
   if (e instanceof DispositionReportFaultMessage) {
      DispositionReportFaultMessage faultMsg = (DispositionReportFaultMessage) e;
      report = faultMsg.getFaultInfo();
   } else if (e instanceof SOAPFaultException) {
      SOAPFaultException soapFault = (SOAPFaultException) e;
      Detail detail = soapFault.getFault().getDetail();
      if (detail != null && detail.getFirstChild()!=null) {
         try {
            report =  new DispositionReport(detail.getFirstChild());
         } catch (JAXBException je) {
            log.error("Could not unmarshall detail to a DispositionReport");
         }
      }
   } else if (e instanceof UndeclaredThrowableException) {
      UndeclaredThrowableException ute =(UndeclaredThrowableException) e;
      if (ute.getUndeclaredThrowable()!=null && ute.getUndeclaredThrowable().getCause()!=null
          && ute.getUndeclaredThrowable().getCause().getCause() instanceof DispositionReportFaultMessage) {
         DispositionReportFaultMessage faultMsg = (DispositionReportFaultMessage) ute.getUndeclaredThrowable().getCause().getCause();
         report = faultMsg.getFaultInfo();
      }
   } else {
      log.error("Unsupported Exception: " + e.getClass());
   }
   return report;
}