/*
 * (c) Copyright 2008-2010 by Volker Bergmann. All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, is permitted under the terms of the
 * GNU General Public License.
 *
 * For redistributing this software or a derivative work under a license other
 * than the GPL-compatible Free Software License as defined by the Free
 * Software Foundation or approved by OSI, you must first obtain a commercial
 * license to this software product from Volker Bergmann.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 * WITHOUT A WARRANTY OF ANY KIND. ALL EXPRESS OR IMPLIED CONDITIONS,
 * REPRESENTATIONS AND WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE
 * HEREBY EXCLUDED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 * POSSIBILITY OF SUCH DAMAGE.
 */

package org.databene.commons;

/**
 * Indicates a parsing error.<br/>
 * <br/>
 * Created at 30.12.2008 08:23:05
 * @since 0.5.7
 * @author Volker Bergmann
 */

public class ParseException extends RuntimeException {
	
	private final String parsedText;
	private final int line;
	private final int column;
	
	// constructors ----------------------------------------------------------------------------------------------------

	public ParseException(String message, String parsedText) {
		this(message, parsedText, -1, -1);
	}

	public ParseException(String message, String parsedText, int line, int column) {
		super(message);
		this.parsedText = parsedText;
		this.line = line;
		this.column = column;
	}
	
	public ParseException(String message, Throwable cause, String parsedText, int line, int column) {
		super(message, cause);
		this.parsedText = parsedText;
		this.line = line;
		this.column = column;
	}
	
	// properties ------------------------------------------------------------------------------------------------------

	public int getLine() {
		return line;
	}

	public int getColumn() {
		return column;
	}
	
	public String getParsedText() {
    	return parsedText;
    }

	@Override
	public String toString() {
		StringBuilder builder = new StringBuilder(getMessage());
		if (line >= 0 && column >= 0)
			builder.append(" at line ").append(line).append(", column ").append(column).append(" of ");
		else
			builder.append(" in ");
		builder.append(parsedText);
	    return builder.toString();
	}
	
	private static final long serialVersionUID = -3893735778927506664L;

}

@@ -1588,16 +1588,87 @@
 ion %7B%0A%09%0A
+%09private static final long serialVersionUID = -3893735778927506664L;%0A%09%0A
 %09private
@@ -1693,16 +1693,16 @@
 edText;%0A
-
 %09private
@@ -1747,16 +1747,20 @@
 lumn;%0A%09%0A
+%09%0A%09%0A
 %09// cons
@@ -2055,29 +2055,28 @@
 mn) %7B%0A%09%09
-super
+this
 (message
 );%0A%09%09thi
@@ -2071,85 +2071,41 @@
 sage
-);%0A%09%09this.parsedText = parsedText;%0A%09%09this.line = line;%0A%09%09this.column =
+, null, parsedText, line,
  column
+)
 ;%0A%09%7D
@@ -2312,16 +2312,20 @@
 n;%0A%09%7D%0A%09%0A
+%09%0A%09%0A
 %09// prop
@@ -2589,17 +2589,18 @@
 ;%0A    %7D%0A
+%09
 %0A
-
 %09@Overri
@@ -2919,78 +2919,8 @@
 %0A%09%7D%0A
+
 %09%0A
-%09private static final long serialVersionUID = -3893735778927506664L;%0A%0A
 %7D%0A

Simplified code