001 /*
002 * Licensed to the Apache Software Foundation (ASF) under one or more
003 * contributor license agreements. See the NOTICE file distributed with
004 * this work for additional information regarding copyright ownership.
005 * The ASF licenses this file to You under the Apache License, Version 2.0
006 * (the "License"); you may not use this file except in compliance with
007 * the License. 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 package org.apache.commons.resources;
019
020 import java.io.Serializable;
021
022 /**
023 * <p>This class is a general purpose wrapper exception for problems
024 * pertaining to Resources.</p>
025 */
026 public class ResourcesException extends RuntimeException implements Serializable {
027
028 /** Exception message */
029 private String message = "";
030
031 /** Cause of the exception */
032 private Throwable rootCause = null;
033
034 /**
035 * Construct an Exception with the specified message.
036 * @param message The message.
037 */
038 public ResourcesException(String message) {
039 this(message, null);
040 }
041
042 /**
043 * Construct an Exception with the specified cause.
044 * @param rootCause Cause of the exception.
045 */
046 public ResourcesException(Throwable rootCause) {
047 this.message = rootCause.getMessage();
048 this.rootCause = rootCause;
049 }
050
051 /**
052 * Construct an Exception with the specified message.
053 * and cause.
054 * @param message The message.
055 * @param rootCause Cause of the exception.
056 */
057 public ResourcesException(String message, Throwable rootCause) {
058 this.message = message;
059 this.rootCause = rootCause;
060 }
061
062 /**
063 * Return the message.
064 * @return The message.
065 */
066 public String getMessage() {
067 return message;
068 }
069
070 /**
071 * Return the cause.
072 * @return The cause of the Exception.
073 */
074 public Throwable getRootCause() {
075 return rootCause;
076 }
077 }