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