001    /*
002     * Copyright (c) OSGi Alliance (2001, 2008). All Rights Reserved.
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 org.osgi.service.cm;
017    
018    /**
019     * An <code>Exception</code> class to inform the Configuration Admin service
020     * of problems with configuration data.
021     * 
022     * @version $Revision: 6083 $
023     */
024    public class ConfigurationException extends Exception {
025            static final long       serialVersionUID        = -1690090413441769377L;
026    
027            private final String            property;
028            private final String            reason;
029    
030            /**
031             * Create a <code>ConfigurationException</code> object.
032             * 
033             * @param property name of the property that caused the problem,
034             *        <code>null</code> if no specific property was the cause
035             * @param reason reason for failure
036             */
037            public ConfigurationException(String property, String reason) {
038                    super(property + " : " + reason);
039                    this.property = property;
040                    this.reason = reason;
041            }
042    
043            /**
044             * Create a <code>ConfigurationException</code> object.
045             * 
046             * @param property name of the property that caused the problem,
047             *        <code>null</code> if no specific property was the cause
048             * @param reason reason for failure
049             * @param cause The cause of this exception.
050             * @since 1.2
051             */
052            public ConfigurationException(String property, String reason,
053                            Throwable cause) {
054                    super(property + " : " + reason, cause);
055                    this.property = property;
056                    this.reason = reason;
057            }
058    
059            /**
060             * Return the property name that caused the failure or null.
061             * 
062             * @return name of property or null if no specific property caused the
063             *         problem
064             */
065            public String getProperty() {
066                    return property;
067            }
068    
069            /**
070             * Return the reason for this exception.
071             * 
072             * @return reason of the failure
073             */
074            public String getReason() {
075                    return reason;
076            }
077            
078            /**
079             * Returns the cause of this exception or <code>null</code> if no cause was
080             * set.
081             * 
082             * @return The cause of this exception or <code>null</code> if no cause was
083             *         set.
084             * @since 1.2
085             */
086            public Throwable getCause() {
087                    return super.getCause();
088            }
089    
090            /**
091             * Initializes the cause of this exception to the specified value.
092             * 
093             * @param cause The cause of this exception.
094             * @return This exception.
095             * @throws IllegalArgumentException If the specified cause is this
096             *         exception.
097             * @throws IllegalStateException If the cause of this exception has already
098             *         been set.
099             * @since 1.2
100             */
101            public Throwable initCause(Throwable cause) {
102                    return super.initCause(cause);
103            }
104    }