001    /*--------------------------------------------------------------------------+
002    $Id: MDLParserException.java 26285 2010-02-18 11:22:54Z juergens $
003    |                                                                          |
004    | Copyright 2005-2010 Technische Universitaet Muenchen                     |
005    |                                                                          |
006    | Licensed under the Apache License, Version 2.0 (the "License");          |
007    | you may not use this file except in compliance with the License.         |
008    | You may obtain a copy of the License at                                  |
009    |                                                                          |
010    |    http://www.apache.org/licenses/LICENSE-2.0                            |
011    |                                                                          |
012    | Unless required by applicable law or agreed to in writing, software      |
013    | distributed under the License is distributed on an "AS IS" BASIS,        |
014    | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
015    | See the License for the specific language governing permissions and      |
016    | limitations under the License.                                           |
017    +--------------------------------------------------------------------------*/
018    package edu.tum.cs.simulink.builder;
019    
020    /**
021     * Exception thrown by the MDL parser. Exceptions may wrap other exceptions. *
022     * 
023     * @author Florian Deissenboeck
024     * @author $Author: juergens $
025     * @version $Rev: 26285 $
026     * @levd.rating GREEN Hash: 56E0BD5F648605D97FBE7D74B24B7942
027     */
028    @SuppressWarnings("serial")
029    public class MDLParserException extends Exception {
030    
031            /** number of line where exception occurred. */
032            private int lineNumber;
033    
034            /** number of column where exception occurred. */
035            private int columnNumber;
036    
037            /**
038             * Create new parser exception.
039             */
040            public MDLParserException(String message) {
041                    super(message);
042            }
043    
044            /**
045             * Create new parser exception.
046             * 
047             * @param message
048             *            exception description
049             * @param lineNumber
050             *            line in the input file where problem occurred
051             * @param columnNumber
052             *            column in the input file where problem occurred
053             */
054            public MDLParserException(String message, int lineNumber, int columnNumber) {
055                    super(message + " [line: " + lineNumber + ", col: " + columnNumber
056                                    + "]");
057                    this.lineNumber = lineNumber;
058                    this.columnNumber = columnNumber;
059            }
060    
061            /**
062             * Create new parser exception wrapping another exception.
063             */
064            public MDLParserException(Exception exception) {
065                    super("Unknown Exception caused by: " + exception.getMessage(),
066                                    exception);
067            }
068    
069            /**
070             * Get line in the input file where problem occurred.
071             */
072            public int getColumnNumber() {
073                    return columnNumber;
074            }
075    
076            /**
077             * Get column in the input file where problem occurred.
078             */
079            public int getLineNumber() {
080                    return lineNumber;
081            }
082    
083    }