01: package org.relaxng.datatype;
02:
03: /**
04: * Signals Datatype related exceptions.
05: *
06: * @author <a href="mailto:jjc@jclark.com">James Clark</a>
07: * @author <a href="mailto:kohsuke.kawaguchi@sun.com">Kohsuke KAWAGUCHI</a>
08: */
09: public class DatatypeException extends Exception {
10:
11: public DatatypeException(int index, String msg) {
12: super (msg);
13: this .index = index;
14: }
15:
16: public DatatypeException(String msg) {
17: this (UNKNOWN, msg);
18: }
19:
20: /**
21: * A constructor for those datatype libraries which don't support any
22: * diagnostic information at all.
23: */
24: public DatatypeException() {
25: this (UNKNOWN, null);
26: }
27:
28: private final int index;
29:
30: public static final int UNKNOWN = -1;
31:
32: /**
33: * Gets the index of the content where the error occured.
34: * UNKNOWN can be returned to indicate that no index information
35: * is available.
36: */
37: public int getIndex() {
38: return index;
39: }
40: }
|