/**
 * 
 */
package org.metaborg.meta.interpreter.framework;

import org.spoofax.terms.TermFactory;

/**
 * @author vladvergu
 * 
 */
public class InterpreterException extends RuntimeException {

	/**
	 * 
	 */
	private static final long serialVersionUID = -4486855230813687971L;

	private final String arrowname;
	private final Object term;

	public InterpreterException(String msg, String arrowname, Object term,
			Throwable t) {
		super(msg + " in arrow: " + arrowname + " on term: "
				+ termToString(term));
		this.arrowname = arrowname;
		this.term = term;
	}

	private static String termToString(Object t) {
		if (t != null && t instanceof IConvertibleToStrategoTerm) {
			return ((IConvertibleToStrategoTerm) t).toStrategoTerm(
					new TermFactory()).toString(120);
		}
		return t + "";
	}

	public InterpreterException(String msg, String arrowname, Object term) {
		this(msg, arrowname, term, null);
	}

	public InterpreterException(String msg) {
		this(msg, null, null, null);
	}

	public String getArrowName() {
		return arrowname;
	}

	public Object getTerm() {
		return term;
	}

}

@@ -336,16 +336,320 @@
  term;%0A%0A
+%09public InterpreterException(String msg) %7B%0A%09%09this(msg, null, null, null);%0A%09%7D%0A%0A%09public InterpreterException(String msg, String arrowname, Object term) %7B%0A%09%09this(msg, arrowname, term, null);%0A%09%7D%0A%0A%09public InterpreterException(String msg, Throwable t) %7B%0A%09%09super(msg, t);%0A%09%09term = null;%0A%09%09arrowname = null;%0A%09%7D%0A%0A
 %09public 
@@ -712,16 +712,16 @@
 t term,%0A
-
 %09%09%09Throw
@@ -809,16 +809,19 @@
 ng(term)
+, t
 );%0A%09%09thi
@@ -1081,16 +1081,16 @@
 0);%0A%09%09%7D%0A
+
 %09%09return
@@ -1106,200 +1106,8 @@
 %09%7D%0A%0A
-%09public InterpreterException(String msg, String arrowname, Object term) %7B%0A%09%09this(msg, arrowname, term, null);%0A%09%7D%0A%0A%09public InterpreterException(String msg) %7B%0A%09%09this(msg, null, null, null);%0A%09%7D%0A%0A
 %09pub

Make InterpreterException usable for non-reduction exceptions as well