001/*
002 * Licensed to the Apache Software Foundation (ASF) under one
003 * or more contributor license agreements.  See the NOTICE file
004 * distributed with this work for additional information
005 * regarding copyright ownership.  The ASF licenses this file
006 * to you under the Apache License, Version 2.0 (the
007 * "License"); you may not use this file except in compliance
008 * with the License.  You may obtain a copy of the License at
009 *
010 *   http://www.apache.org/licenses/LICENSE-2.0
011 *
012 * Unless required by applicable law or agreed to in writing,
013 * software distributed under the License is distributed on an
014 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
015 * KIND, either express or implied.  See the License for the
016 * specific language governing permissions and limitations
017 * under the License.
018 */
019package org.apache.maven.enforcer.rule.api;
020
021/**
022 * An exception occurring during the execution of a rule.
023 * <p>
024 * Enforcer plugin takes decision based on configuration and {@code Enforcer Rule} level
025 * whether build should pass or fail.
026 *
027 * @author <a href="mailto:brianf@apache.org">Brian Fox</a>
028 */
029public class EnforcerRuleException extends Exception {
030
031    /** serialVersionUID. */
032    private static final long serialVersionUID = 1L;
033
034    /** The source. */
035    protected Object source;
036
037    /** The long message. */
038    protected String longMessage;
039
040    /**
041     * Gets the long message.
042     *
043     * @return the long message
044     * @deprecated not used
045     */
046    @Deprecated
047    public String getLongMessage() {
048        return longMessage;
049    }
050
051    /**
052     * Gets the source.
053     *
054     * @return the source
055     * @deprecated not used
056     */
057    @Deprecated
058    public Object getSource() {
059        return source;
060    }
061
062    /**
063     * Construct a new <code>EnforcerRuleException</code> exception providing
064     * the source and a short and long message.
065     *
066     * @param source       the source
067     * @param shortMessage the short message
068     * @param longMessage  the long message
069     * @deprecated {@code source} and {@code longMessage} are not used
070     */
071    @Deprecated
072    public EnforcerRuleException(Object source, String shortMessage, String longMessage) {
073        super(shortMessage);
074        this.source = source;
075        this.longMessage = longMessage;
076    }
077
078    /**
079     * Construct a new <code>EnforcerRuleException</code> exception wrapping
080     * an underlying <code>Exception</code> and providing a
081     * <code>message</code>.
082     *
083     * @param message the message
084     * @param cause   the cause
085     */
086    public EnforcerRuleException(String message, Exception cause) {
087        super(message, cause);
088    }
089
090    /**
091     * Construct a new <code>EnforcerRuleException</code> exception wrapping
092     * an underlying <code>Throwable</code> and providing a
093     * <code>message</code>.
094     *
095     * @param message the message
096     * @param cause   the cause
097     */
098    public EnforcerRuleException(String message, Throwable cause) {
099        super(message, cause);
100    }
101
102    /**
103     * Construct a new <code>EnforcerRuleException</code> exception providing
104     * a <code>message</code>.
105     *
106     * @param message the message
107     */
108    public EnforcerRuleException(String message) {
109        super(message);
110    }
111
112    /**
113     * Construct a new <code>EnforcerRuleException</code> exception wrapping
114     * an underlying <code>Throwable</code>.
115     *
116     * @param cause the cause
117     */
118    public EnforcerRuleException(Throwable cause) {
119        super(cause);
120    }
121}