001package org.relaxng.datatype;
002
003/**
004 * Signals Datatype related exceptions.
005 * 
006 * @author <a href="mailto:jjc@jclark.com">James Clark</a>
007 * @author <a href="mailto:kohsuke.kawaguchi@sun.com">Kohsuke KAWAGUCHI</a>
008 */
009public class DatatypeException extends Exception {
010        
011        public DatatypeException( int index, String msg ) {
012                super(msg);
013                this.index = index;
014        }
015        public DatatypeException( String msg ) {
016                this(UNKNOWN,msg);
017        }
018        /**
019         * A constructor for those datatype libraries which don't support any
020         * diagnostic information at all.
021         */
022        public DatatypeException() {
023                this(UNKNOWN,null);
024        }
025        
026        
027        private final int index;
028        
029        public static final int UNKNOWN = -1;
030
031        /**
032         * Gets the index of the content where the error occured.
033         * UNKNOWN can be returned to indicate that no index information
034         * is available.
035         */
036        public int getIndex() {
037                return index;
038        }
039}