package org.supercsv.exception;

import java.io.Serializable;

import org.supercsv.cellprocessor.ift.CellProcessor;
import org.supercsv.util.CSVContext;

/** If anything goes wrong, we throw one of these bad boys here */
public class SuperCSVException extends RuntimeException implements Serializable {
private static final long serialVersionUID = 1L;
private CSVContext csvContext;
private CellProcessor offendingProcessor;

public SuperCSVException(final String msg) {
	super(msg);
}

public SuperCSVException(final String msg, final CSVContext context) {
	super(msg);
	this.csvContext = context;
}

public SuperCSVException(final String msg, final CSVContext context, final Throwable t) {
	super(msg, t);
	this.csvContext = context;
}

public SuperCSVException(final String msg, final CellProcessor processor) {
	super(msg);
	this.offendingProcessor = processor;
}

public SuperCSVException(final String msg, final CSVContext context, final CellProcessor processor) {
	super(msg);
	this.csvContext = context;
	this.offendingProcessor = processor;
}

public SuperCSVException(final String msg, final CSVContext context, final CellProcessor processor, final Throwable t) {
	super(msg, t);
	this.csvContext = context;
	this.offendingProcessor = processor;
}

/**
 * The context may be null when exceptions are thrown before or after processing, such as in cell offendingProcessor's
 * <code>init()</code> methods.
 * 
 * @return null, or the context of the cvs file
 */
public CSVContext getCsvContext() {
	return csvContext;
}

/**
 * Think twice before invoking this...
 * 
 * @param csvContext
 *            the new context
 */
public void setCsvContext(final CSVContext csvContext) {
	this.csvContext = csvContext;
}

public CellProcessor getOffendingProcessor() {
	return offendingProcessor;
}

}

@@ -707,32 +707,56 @@
 le t) %7B%0D%0A%09super(
+t.getMessage() + %22%5Cn%22 + 
 msg, t);%0D%0A%09this.
@@ -741,32 +741,32 @@
 %5Cn%22 + msg, t);%0D%0A
-
 %09this.csvContext
@@ -1237,16 +1237,40 @@
 %0A%09super(
+t.getMessage() + %22%5Cn%22 + 
 msg, t);
@@ -1909,11 +1909,153 @@
 ;%0D%0A%7D%0D%0A%0D%0A
+@Override%0D%0Apublic String toString() %7B%0D%0A%09return getMessage() + %22 %22 + csvContext.toString() + %22 offending processor %22 + offendingProcessor;%0D%0A%7D%0D%0A
 %7D%0D%0A

merging exception message with provided message for better error message output