KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > mule > providers > soap > axis > AxisFaultExceptionReader


1 /*
2  * $Id: AxisFaultExceptionReader.java 3798 2006-11-04 04:07:14Z aperepel $
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 MuleSource MPL
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.apache.axis.AxisFault;
14 import org.mule.config.ExceptionReader;
15
16 import java.util.HashMap JavaDoc;
17 import java.util.Iterator JavaDoc;
18 import java.util.Map JavaDoc;
19
20 /**
21  * Will format and display additional information stored with an Axis fault that is
22  * usually hidden when logged
23  *
24  * @author <a HREF="mailto:ross.mason@symphonysoft.com">Ross Mason</a>
25  * @version $Revision: 3798 $
26  */

27 public class AxisFaultExceptionReader implements ExceptionReader
28 {
29
30     public String JavaDoc getMessage(Throwable JavaDoc t)
31     {
32         AxisFault e = (AxisFault)t;
33         Map JavaDoc props = getInfo(e);
34         StringBuffer JavaDoc msg = new StringBuffer JavaDoc(64);
35         msg.append("(");
36         for (Iterator JavaDoc iterator = props.entrySet().iterator(); iterator.hasNext();)
37         {
38             Map.Entry JavaDoc entry = (Map.Entry JavaDoc)iterator.next();
39             msg.append(entry.getKey()).append(": ").append(entry.getValue()).append(", ");
40         }
41         msg.append(")");
42         return e.getMessage() + msg.toString();
43     }
44
45     public Throwable JavaDoc getCause(Throwable JavaDoc t)
46     {
47         AxisFault e = (AxisFault)t;
48         Throwable JavaDoc cause = e.detail;
49         if (cause == null)
50         {
51             cause = e.getCause();
52         }
53         return cause;
54     }
55
56     public Class JavaDoc getExceptionType()
57     {
58         return AxisFault.class;
59     }
60
61     /**
62      * Returns a map of the non-stanard information stored on the exception
63      *
64      * @return a map of the non-stanard information stored on the exception
65      */

66     public Map JavaDoc getInfo(Throwable JavaDoc t)
67     {
68         AxisFault e = (AxisFault)t;
69         Map JavaDoc info = new HashMap JavaDoc();
70         info.put("Fault", e.getFaultString());
71         info.put("Fault Code", e.getFaultCode().toString());
72         info.put("Fault Actor", e.getFaultActor());
73         info.put("Fault Node", e.getFaultNode());
74         info.put("Fault Reason", e.getFaultReason());
75         info.put("Fault Role", e.getFaultRole());
76         info.put("Fault Dump", e.dumpToString());
77         // Todo Do we need to out put headers and elements or are these part of the
78
// dumpToString??
79
return info;
80     }
81 }
82
Popular Tags