001package org.apache.commons.jcs.utils.config;
002
003/*
004 * Licensed to the Apache Software Foundation (ASF) under one
005 * or more contributor license agreements.  See the NOTICE file
006 * distributed with this work for additional information
007 * regarding copyright ownership.  The ASF licenses this file
008 * to you under the Apache License, Version 2.0 (the
009 * "License"); you may not use this file except in compliance
010 * with the License.  You may obtain a copy of the License at
011 *
012 *   http://www.apache.org/licenses/LICENSE-2.0
013 *
014 * Unless required by applicable law or agreed to in writing,
015 * software distributed under the License is distributed on an
016 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
017 * KIND, either express or implied.  See the License for the
018 * specific language governing permissions and limitations
019 * under the License.
020 */
021
022/**
023 * This class is based on the log4j class org.apache.log4j.config.PropertySetter that was made by
024 * Anders Kristensen
025 * <p>
026 * Thrown when an error is encountered whilst attempting to set a property using the
027 * {@link PropertySetter}utility class.
028 */
029public class PropertySetterException
030    extends Exception
031{
032    /** DOn't change */
033    private static final long serialVersionUID = -210271658004609028L;
034
035    /** Description of the Field */
036    private final Throwable rootCause;
037
038    /**
039     * Constructor for the PropertySetterException object
040     * <p>
041     * @param msg
042     */
043    public PropertySetterException( String msg )
044    {
045        super( msg );
046        this.rootCause = null;
047    }
048
049    /**
050     * Constructor for the PropertySetterException object
051     * <p>
052     * @param rootCause
053     */
054    public PropertySetterException( Throwable rootCause )
055    {
056        super();
057        this.rootCause = rootCause;
058    }
059
060    /**
061     * Returns descriptive text on the cause of this exception.
062     * <p>
063     * @return The message value
064     */
065    @Override
066    public String getMessage()
067    {
068        String msg = super.getMessage();
069        if ( msg == null && rootCause != null )
070        {
071            msg = rootCause.getMessage();
072        }
073        return msg;
074    }
075}