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 package org.apache.log4j.config;
018
019 /**
020 * Thrown when an error is encountered whilst attempting to set a property
021 * using the {@link PropertySetter} utility class.
022 *
023 * @since 1.1
024 */
025 public class PropertySetterException extends Exception {
026 private static final long serialVersionUID = -1352613734254235861L;
027
028 /**
029 * The root cause.
030 */
031 protected Throwable rootCause;
032
033 /**
034 * Construct the exception with the given message.
035 *
036 * @param msg The message
037 */
038 public PropertySetterException(final String msg) {
039 super(msg);
040 }
041
042 /**
043 * Construct the exception with the given root cause.
044 *
045 * @param rootCause The root cause
046 */
047 public PropertySetterException(final Throwable rootCause) {
048 super();
049 this.rootCause = rootCause;
050 }
051
052 /**
053 * Returns descriptive text on the cause of this exception.
054 *
055 * @return the descriptive text.
056 */
057 @Override
058 public String getMessage() {
059 String msg = super.getMessage();
060 if (msg == null && rootCause != null) {
061 msg = rootCause.getMessage();
062 }
063 return msg;
064 }
065 }