001    /*
002     * Copyright 2001-2004 The Apache Software Foundation.
003     * 
004     * Licensed under the Apache License, Version 2.0 (the "License");
005     * you may not use this file except in compliance with the License.
006     * You may obtain a copy of the License at
007     * 
008     *      http://www.apache.org/licenses/LICENSE-2.0
009     * 
010     * Unless required by applicable law or agreed to in writing, software
011     * distributed under the License is distributed on an "AS IS" BASIS,
012     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013     * See the License for the specific language governing permissions and
014     * limitations under the License.
015     */
016    package javax.xml.rpc;
017    
018    /**
019     * The <code>javax.xml.rpc.ServiceException</code> is thrown from the
020     * methods in the <code>javax.xml.rpc.Service</code> interface and
021     * <code>ServiceFactory</code> class.
022     *
023     *
024     * @version 1.0
025     */
026    public class ServiceException extends Exception {
027        
028        // fixme: could we refactor this to use the jdk1.4 exception wrapping stuff?
029        
030        /** The cause of this exception. */
031        Throwable cause;
032        
033        /**
034         * Constructs a new exception with <code>null</code> as its
035         * detail message. The cause is not initialized.
036         */
037        public ServiceException() {}
038        
039        /**
040         * Constructs a new exception with the specified detail
041         * message.  The cause is not initialized.
042         *
043         * @param message The detail message which is later
044         *            retrieved using the <code>getMessage</code> method
045         */
046        public ServiceException(String message) {
047            super(message);
048        }
049        
050        /**
051         * Constructs a new exception with the specified detail
052         * message and cause.
053         *
054         * @param message the detail message which is later retrieved
055         *            using the <code>getMessage</code> method
056         * @param cause the cause which is saved for the later
057         *            retrieval throw by the <code>getCause</code>
058         *            method
059         */
060        public ServiceException(String message, Throwable cause) {
061            super(message);
062            this.cause = cause;
063        }
064        
065        /**
066         * Constructs a new exception with the specified cause
067         * and a detail message of <tt>(cause==null ? null :
068         * cause.toString())</tt> (which typically contains the
069         * class and detail message of <tt>cause</tt>).
070         *
071         * @param cause the cause which is saved for the later
072         *            retrieval throw by the getCause method.
073         *            (A <tt>null</tt> value is permitted, and
074         *            indicates that the cause is nonexistent or
075         *          unknown.)
076         */
077        public ServiceException(Throwable cause) {
078            super( (cause == null) ? null : cause.toString() );
079            this.cause = cause;
080        }
081        
082        /**
083         * Gets the linked cause.
084         *
085         * @return the cause of this Exception or <code>null</code>
086         *     if the cause is noexistent or unknown
087         */
088        public Throwable getLinkedCause() {
089            return cause;
090        }
091        
092    }