KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > axis2 > engine > AxisFault


1 /*
2  * Copyright 2004,2005 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16 package org.apache.axis2.engine;
17
18 import java.lang.reflect.InvocationTargetException JavaDoc;
19
20 /**
21  * An exception which maps cleanly to a SOAP fault.
22  * This is a base class for exceptions which are mapped to faults.
23  * SOAP faults contain
24  * <ol>
25  * <li>A fault string
26  * <li>A fault code
27  * <li>A fault actor
28  * <li>Fault details; an xml tree of fault specific stuff
29  * </ol>
30  */

31 public class AxisFault extends java.rmi.RemoteException JavaDoc {
32  
33     public AxisFault(Throwable JavaDoc arg1) {
34          super(arg1.getMessage(), arg1);
35      }
36     /**
37      * @param arg0
38      */

39     public AxisFault(String JavaDoc arg0) {
40         super(arg0);
41    }
42
43     /**
44      * @param arg0
45      * @param arg1
46      */

47     public AxisFault(String JavaDoc arg0, Throwable JavaDoc arg1) {
48         super(arg0, arg1);
49     }
50
51     /**
52      * Make an AxisFault based on a passed Exception. If the Exception is
53      * already an AxisFault, simply use that. Otherwise, wrap it in an
54      * AxisFault. If the Exception is an InvocationTargetException (which
55      * already wraps another Exception), get the wrapped Exception out from
56      * there and use that instead of the passed one.
57      *
58      * @param e the <code>Exception</code> to build a fault for
59      * @return an <code>AxisFault</code> representing <code>e</code>
60      */

61     public static AxisFault makeFault(Exception JavaDoc e) {
62         if (e instanceof InvocationTargetException JavaDoc) {
63             Throwable JavaDoc t = ((InvocationTargetException JavaDoc) e).getTargetException();
64             if (t instanceof Exception JavaDoc) {
65                 e = (Exception JavaDoc) t;
66             }
67         }
68         if (e instanceof AxisFault) {
69             return (AxisFault) e;
70         }
71         return new AxisFault(e.getMessage(), e);
72     }
73 }
74
Popular Tags