001    /*
002    // $Id: MdxParseException.java 482 2012-01-05 23:27:27Z jhyde $
003    //
004    // Licensed to Julian Hyde under one or more contributor license
005    // agreements. See the NOTICE file distributed with this work for
006    // additional information regarding copyright ownership.
007    //
008    // Julian Hyde licenses this file to you under the Apache License,
009    // Version 2.0 (the "License"); you may not use this file except in
010    // compliance with the License. You may obtain a copy of the License at:
011    //
012    // http://www.apache.org/licenses/LICENSE-2.0
013    //
014    // Unless required by applicable law or agreed to in writing, software
015    // distributed under the License is distributed on an "AS IS" BASIS,
016    // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
017    // See the License for the specific language governing permissions and
018    // limitations under the License.
019    */
020    package org.olap4j.mdx.parser;
021    
022    import org.olap4j.mdx.ParseRegion;
023    
024    /**
025     * Exception thrown by an {@link org.olap4j.mdx.parser.MdxParser} to
026     * indicate an error in parsing. Has a {@link org.olap4j.mdx.ParseRegion}.
027     *
028     * @author jhyde
029     * @version $Id: MdxParseException.java 482 2012-01-05 23:27:27Z jhyde $
030     */
031    public class MdxParseException extends RuntimeException {
032        private final ParseRegion region;
033    
034        /**
035         * Creates an MdxParseException with a region of the source code and a
036         * specified cause.
037         *
038         * @param region Region of source code which contains the error
039         *
040         * @param  cause the cause (which is saved for later retrieval by the
041         *         {@link #getCause()} method).  (A <tt>null</tt> value is
042         *         permitted, and indicates that the cause is nonexistent or
043         *         unknown.)
044         */
045        public MdxParseException(ParseRegion region, Throwable cause) {
046            super(cause);
047            this.region = region;
048        }
049    
050        /**
051         * Creates an MdxParseException with a region of the source code and a
052         * specified detail message.
053         *
054         * @param region Region of source code which contains the error
055         *
056         * @param   message   the detail message. The detail message is saved for
057         *          later retrieval by the {@link #getMessage()} method.
058         */
059        public MdxParseException(ParseRegion region, String message) {
060            super(message);
061            this.region = region;
062        }
063    
064        public ParseRegion getRegion() {
065            return region;
066        }
067    }
068    
069    // End MdxParseException.java