Coverage Report - org.apache.xmlrpc.XmlRpcException
 
Classes in this File Line Coverage Branch Coverage Complexity
XmlRpcException
30% 
0% 
1,333
 
 1  
 /*
 2  
  * Copyright 1999,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.xmlrpc;
 17  
 
 18  
 import java.io.PrintStream;
 19  
 import java.io.PrintWriter;
 20  
 
 21  
 /** This exception is thrown by the XmlRpcClient, if an invocation of the
 22  
  * remote method failed. Failure may have two reasons: The invocation
 23  
  * failed on the remote side (for example, an exception was thrown within
 24  
  * the server) or the communication with the server failed. The latter
 25  
  * is indicated by throwing an instance of
 26  
  * {@link org.apache.xmlrpc.client.XmlRpcClientException}.
 27  
  */
 28  
 public class XmlRpcException extends Exception {
 29  
         private static final long serialVersionUID = 3258693217049325618L;
 30  
 
 31  
         /** The fault code of the exception. For servers based on this library, this
 32  
      * will always be 0. (If there are predefined error codes, they should be in
 33  
      * the XML-RPC spec.)
 34  
      */
 35  
     public final int code;
 36  
 
 37  
         /** If the transport was able to catch a remote exception
 38  
          * (as is the case, if the local transport is used or if extensions
 39  
          * are enabled and the server returned a serialized exception),
 40  
          * then this field contains the trapped exception.
 41  
          */
 42  
         public final Throwable linkedException;
 43  
 
 44  
     /** Creates a new instance with the given error code and error message.
 45  
      * @param pCode Error code.
 46  
      * @param pMessage Detail message.
 47  
      */
 48  
     public XmlRpcException(int pCode, String pMessage) {
 49  117
                 this(pCode, pMessage, null);
 50  117
     }
 51  
 
 52  
     /** Creates a new instance with the given error message
 53  
      * and cause.
 54  
      * @param pMessage Detail message.
 55  
      * @param pLinkedException The errors cause.
 56  
      */
 57  
     public XmlRpcException(String pMessage, Throwable pLinkedException) {
 58  0
                 this(0, pMessage, pLinkedException);
 59  0
     }
 60  
 
 61  
     /** Creates a new instance with the given error message
 62  
      * and error code 0.
 63  
      * @param pMessage Detail message.
 64  
      */
 65  
     public XmlRpcException(String pMessage) {
 66  0
                 this(0, pMessage, null);
 67  0
     }
 68  
 
 69  
     /** Creates a new instance with the given error code, error message
 70  
      * and cause.
 71  
      * @param pCode Error code.
 72  
      * @param pMessage Detail message.
 73  
      * @param pLinkedException The errors cause.
 74  
      */
 75  
     public XmlRpcException(int pCode, String pMessage, Throwable pLinkedException) {
 76  117
                 super(pMessage);
 77  117
                 code = pCode;
 78  117
                 linkedException = pLinkedException;
 79  117
     }
 80  
 
 81  
         public void printStackTrace(PrintStream pStream) {
 82  0
                 super.printStackTrace(pStream);
 83  0
                 if (linkedException != null) {
 84  0
                         pStream.println("Caused by:");
 85  
                 }
 86  0
                 linkedException.printStackTrace(pStream);
 87  0
         }
 88  
 
 89  
         public void printStackTrace(PrintWriter pWriter) {
 90  0
                 super.printStackTrace(pWriter);
 91  0
                 if (linkedException != null) {
 92  0
                         pWriter.println("Caused by:");
 93  0
                         linkedException.printStackTrace(pWriter);
 94  
                 }
 95  0
         }
 96  
 }