Updated error messages when an error occurs within an executable array
[DTRules.git] / DTRules / src / main / java / com / dtrules / infrastructure / RulesException.java
blob09b189f3b35dbfa19b7f0bf02ca92165e7851771
1 /*
2 * $Id$
3 *
4 * Copyright 2004-2007 MTBJ, Inc.
5 *
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 */
19 package com.dtrules.infrastructure;
21 import javax.rules.RuleException;
23 public class RulesException extends RuleException {
24 String errortype;
25 String location;
26 String message;
27 String decisionTable="";
28 String postfix = null;
29 String filename = null;
30 String section = null;
31 int number;
33 public void setPostfix(String s){
34 if(postfix == null){
35 postfix = s;
39 public String getPostfix(){
40 return postfix;
43 /**
44 * Get the DecisionTable under execution at the time the error
45 * occurred. Returns a null if unknown.
46 * @return
48 public String getDecisionTable() {
49 return decisionTable;
52 /**
53 * Set the decisionTable under execution when the error occurred.
54 * @param decisionTable
56 public void addDecisionTable(String decisionTable, String filename) {
57 if(filename==null)filename="";
58 if(this.decisionTable.length()==0){
59 this.decisionTable = decisionTable+" \n";
60 }else {
61 this.decisionTable = this.decisionTable+" called by: "+decisionTable+" \t("+filename+")\n";
63 if(this.filename == null) this.filename = filename;
66 public RulesException(String type, String _location, String _message ){
67 super("Location :"+_location+" type: "+type+" error: "+_message);
68 location = _location;
69 errortype = type;
70 message = _message;
73 static final long serialVersionUID = 0;
75 /**
76 * Provide my view of a Rules Exception;
78 public String toString() {
80 return
81 (decisionTable!="" ? "\nDecision Table: "+decisionTable:"\n") +
82 "File name: "+filename+"\n"+
83 ((section!= null) ? ("Section: "+section + " " + number +"\n"):"")+
84 ((postfix!= null) ? ("Postfix: "+postfix+"\n"):"")+
85 "Location: '"+location+"'\n" +
86 "Type: '"+errortype+"'\n" +
87 "Error: '"+message+"'\n" ;
90 /**
91 * @return the section
93 public String getSection() {
94 return section;
97 /**
98 * @param section the section to set
100 public void setSection(String section, int number) {
101 if(this.section == null){
102 this.section = section;
103 this.number = number;
108 * @return the number
110 public int getNumber() {
111 return number;