001 /**
002 *
003 * Copyright 2003-2004 The Apache Software Foundation
004 *
005 * Licensed under the Apache License, Version 2.0 (the "License");
006 * you may not use this file except in compliance with the License.
007 * You may obtain a copy of the License at
008 *
009 * http://www.apache.org/licenses/LICENSE-2.0
010 *
011 * Unless required by applicable law or agreed to in writing, software
012 * distributed under the License is distributed on an "AS IS" BASIS,
013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014 * See the License for the specific language governing permissions and
015 * limitations under the License.
016 */
017
018 //
019 // This source code implements specifications defined by the Java
020 // Community Process. In order to remain compliant with the specification
021 // DO NOT add / change / or delete method signatures!
022 //
023 package javax.xml.registry;
024
025 /**
026 * Signals that a JAXR exception has occurred.
027 * Note that the Exception chaining here is different from JDK1.4
028 *
029 * @version $Revision$ $Date$
030 */
031 public class JAXRException extends Exception implements JAXRResponse {
032 protected Throwable cause;
033
034 public JAXRException() {
035 }
036
037 public JAXRException(String message) {
038 super(message);
039 }
040
041 public JAXRException(Throwable cause) {
042 super(cause);
043 this.cause = cause;
044 }
045
046 public JAXRException(String message, Throwable cause) {
047 super(message, cause);
048 this.cause = cause;
049 }
050
051 public synchronized Throwable initCause(Throwable cause) {
052
053 if (this.cause != null) {
054 throw new IllegalStateException("Cannot overwrite cause.");
055 }
056
057 this.cause = cause;
058 return this;
059 }
060
061 public String getMessage() {
062 String message = super.getMessage();
063 return (message == null && cause != null) ? cause.getMessage() : message;
064 }
065
066 public Throwable getCause() {
067 return cause;
068 }
069
070 public String getRequestId() {
071 return null;
072 }
073
074 public int getStatus() {
075 return 0;
076 }
077
078 public boolean isAvailable() throws JAXRException {
079 return true;
080 }
081 }