001: package org.drools.spi;
002:
003: /*
004: * Copyright 2005 JBoss Inc
005: *
006: * Licensed under the Apache License, Version 2.0 (the "License");
007: * you may not use this file except in compliance with the License.
008: * 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, software
013: * distributed under the License is distributed on an "AS IS" BASIS,
014: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
015: * See the License for the specific language governing permissions and
016: * limitations under the License.
017: */
018:
019: import org.drools.RuntimeDroolsException;
020: import org.drools.rule.Rule;
021:
022: /**
023: * Indicates an error during a <code>Consequence</code> invocation.
024: *
025: * @see Consequence
026: *
027: * @author <a href="mailto:mark.proctor@jboss.com">Mark Proctor</a>
028: * @author <a href="mailto:bob@werken.com">Bob McWhirter</a>
029: */
030: public class ConsequenceException extends RuntimeDroolsException {
031: /**
032: *
033: */
034: private static final long serialVersionUID = 400L;
035: private Rule rule;
036: private String info;
037:
038: // ------------------------------------------------------------
039: // Constructors
040: // ------------------------------------------------------------
041:
042: /**
043: * Construct.
044: */
045: public ConsequenceException() {
046: // intentionally left blank
047: }
048:
049: public ConsequenceException(final String message) {
050: super (message);
051: }
052:
053: /**
054: * Construct with a root cause.
055: *
056: * @param rootCause
057: * The root cause of this exception.
058: */
059: public ConsequenceException(final Throwable rootCause) {
060: super (rootCause);
061: }
062:
063: public ConsequenceException(final Rule rule) {
064: this .rule = rule;
065: }
066:
067: /**
068: * Construct with a message. Keep this from old ConsequenceException for
069: * backward compatability
070: *
071: * @param rootCause
072: * The root cause of this exception.
073: *
074: *
075: */
076: public ConsequenceException(final String message, final Rule rule) {
077: super (message);
078: this .rule = rule;
079: }
080:
081: /**
082: * Construct with a root cause. Keep this from old ConsequenceException for
083: * backward compatability
084: *
085: * @param rootCause
086: * The root cause of this exception.
087: *
088: *
089: */
090: public ConsequenceException(final Throwable rootCause,
091: final Rule rule) {
092: super (rootCause);
093: this .rule = rule;
094: }
095:
096: public ConsequenceException(final String message, final Rule rule,
097: final String info) {
098: super (message);
099: this .rule = rule;
100: this .info = info;
101: }
102:
103: /**
104: * Construct with a root cause.
105: *
106: * @param rootCause
107: * The root cause of this exception.
108: */
109: public ConsequenceException(final Throwable rootCause,
110: final Rule rule, final String info) {
111: super (rootCause);
112: this .rule = rule;
113: this .info = info;
114: }
115:
116: public Rule getRule() {
117: return this .rule;
118: }
119:
120: /**
121: * Set arbitrary extra information about the condition.
122: *
123: * <p>
124: * The info property may be used to communicate the actual block text or
125: * other information in the case that Consequence does not have block text.
126: * </p>
127: */
128: public void setInfo(final String info) {
129: this .info = info;
130: }
131:
132: public String getInfo() {
133: return this.info;
134: }
135: }
|