Coverage Report - org.mule.transport.soap.axis.AxisFaultExceptionReader
 
Classes in this File Line Coverage Branch Coverage Complexity
AxisFaultExceptionReader
0%
0/25
0%
0/4
0
 
 1  
 /*
 2  
  * $Id: AxisFaultExceptionReader.java 19191 2010-08-25 21:05:23Z tcarlson $
 3  
  * --------------------------------------------------------------------------------------
 4  
  * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.com
 5  
  *
 6  
  * The software in this package is published under the terms of the CPAL v1.0
 7  
  * license, a copy of which has been included with this distribution in the
 8  
  * LICENSE.txt file.
 9  
  */
 10  
 
 11  
 package org.mule.transport.soap.axis;
 12  
 
 13  
 import org.mule.api.config.ExceptionReader;
 14  
 
 15  
 import java.util.HashMap;
 16  
 import java.util.Map;
 17  
 
 18  
 import org.apache.axis.AxisFault;
 19  
 
 20  
 /**
 21  
  * Will format and display additional information stored with an Axis fault that is
 22  
  * usually hidden when logged.
 23  
  */
 24  0
 public class AxisFaultExceptionReader implements ExceptionReader
 25  
 {
 26  
 
 27  
     public String getMessage(Throwable t)
 28  
     {
 29  0
         AxisFault e = (AxisFault)t;
 30  0
         Map<?, ?> props = getInfo(e);
 31  0
         StringBuffer msg = new StringBuffer(64);
 32  0
         msg.append("(");
 33  0
         for (Map.Entry<?, ?> entry : props.entrySet())
 34  
         {
 35  0
             msg.append(entry.getKey()).append(": ").append(entry.getValue()).append(", ");
 36  
         }
 37  0
         msg.append(")");
 38  0
         return e.getMessage() + msg.toString();
 39  
     }
 40  
 
 41  
     public Throwable getCause(Throwable t)
 42  
     {
 43  0
         AxisFault e = (AxisFault)t;
 44  0
         Throwable cause = e.detail;
 45  0
         if (cause == null)
 46  
         {
 47  0
             cause = e.getCause();
 48  
         }
 49  0
         return cause;
 50  
     }
 51  
 
 52  
     public Class<?> getExceptionType()
 53  
     {
 54  0
         return AxisFault.class;
 55  
     }
 56  
 
 57  
     /**
 58  
      * Returns a map of the non-stanard information stored on the exception
 59  
      * 
 60  
      * @return a map of the non-stanard information stored on the exception
 61  
      */
 62  
     public Map<?, ?> getInfo(Throwable t)
 63  
     {
 64  0
         AxisFault e = (AxisFault)t;
 65  0
         Map<String, Object> info = new HashMap<String, Object>();
 66  0
         info.put("Fault", e.getFaultString());
 67  0
         info.put("Fault Code", e.getFaultCode().toString());
 68  0
         info.put("Fault Actor", e.getFaultActor());
 69  0
         info.put("Fault Node", e.getFaultNode());
 70  0
         info.put("Fault Reason", e.getFaultReason());
 71  0
         info.put("Fault Role", e.getFaultRole());
 72  0
         info.put("Fault Dump", e.dumpToString());
 73  
         // Todo Do we need to out put headers and elements or are these part of the
 74  
         // dumpToString??
 75  0
         return info;
 76  
     }
 77  
 }