01: /*
02: * This file is part of PFIXCORE.
03: *
04: * PFIXCORE is free software; you can redistribute it and/or modify
05: * it under the terms of the GNU Lesser General Public License as published by
06: * the Free Software Foundation; either version 2 of the License, or
07: * (at your option) any later version.
08: *
09: * PFIXCORE is distributed in the hope that it will be useful,
10: * but WITHOUT ANY WARRANTY; without even the implied warranty of
11: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12: * GNU Lesser General Public License for more details.
13: *
14: * You should have received a copy of the GNU Lesser General Public License
15: * along with PFIXCORE; if not, write to the Free Software
16: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17: *
18: */
19:
20: package de.schlund.pfixcore.webservice.config;
21:
22: import org.xml.sax.SAXException;
23:
24: /**
25: * ConfigException.java
26: *
27: * Created: 03.08.2004
28: *
29: * @author mleidig@schlund.de
30: */
31: public class ConfigException extends SAXException {
32:
33: public final static int MISSING_ATTRIBUTE = 0;
34: public final static int ILLEGAL_ATTRIBUTE_VALUE = 1;
35:
36: private int type;
37: private String attrName;
38: private String attrVal;
39: private Throwable cause;
40:
41: public ConfigException(int type, String attrName) {
42: super ();
43: this .type = type;
44: this .attrName = attrName;
45: }
46:
47: public ConfigException(int type, String attrName, String attrVal) {
48: super ();
49: this .type = type;
50: this .attrName = attrName;
51: this .attrVal = attrVal;
52: }
53:
54: public ConfigException(int type, String attrName, String attrVal,
55: Throwable cause) {
56: super ();
57: this .type = type;
58: this .attrName = attrName;
59: this .attrVal = attrVal;
60: this .cause = cause;
61: }
62:
63: public String getMessage() {
64: String msg = "";
65: if (type == MISSING_ATTRIBUTE) {
66: msg = "Mandatory attribute '" + attrName + "' is not set.";
67: } else if (type == ILLEGAL_ATTRIBUTE_VALUE) {
68: msg = "Attribute '" + attrName + "' has illegal value: '"
69: + attrVal + "'.";
70: } else
71: msg = "Unknown error";
72: if (cause != null)
73: msg += "[Cause: " + cause.toString() + "]";
74: return msg;
75: }
76:
77: }
|