diff core/src/luan/LuanException.java @ 646:cdc70de628b5

simplify LuanException
author Franklin Schmidt <fschmidt@gmail.com>
date Tue, 29 Mar 2016 19:58:39 -0600
parents 859c0dedc8b6
children 0c334975d526
line wrap: on
line diff
--- a/core/src/luan/LuanException.java	Tue Mar 29 18:09:51 2016 -0600
+++ b/core/src/luan/LuanException.java	Tue Mar 29 19:58:39 2016 -0600
@@ -7,15 +7,23 @@
 public final class LuanException extends Exception implements DeepCloneable {
 	private LuanTable table = new LuanTable();
 
-	private LuanException(String msg,Throwable cause) {
+	public LuanException(String msg,Throwable cause) {
 		super(msg,cause);
+		setTable();
 	}
 
-	public LuanException(LuanState luan,Object msg) throws LuanException {
-		this( luan.toString(msg), msg instanceof Throwable ? (Throwable)msg : null );
+	public LuanException(String msg) {
+		super(msg);
+		setTable();
+	}
+
+	public LuanException(Throwable cause) {
+		super(cause);
+		setTable();
+	}
+
+	private void setTable() {
 		table.rawPut( "java", this );
-		table.rawPut( "message", msg );
-		table.rawPut( "message_string", luan.toString(msg) );
 /*
 		for( StackTraceElement ste : luan.stackTrace ) {
 			LuanTable tbl = new LuanTable();
@@ -28,6 +36,9 @@
 		LuanTable metatable = new LuanTable();
 		table.setMetatable(metatable);
 		try {
+			table.rawPut( "get_message", new LuanJavaFunction(
+				LuanException.class.getMethod( "getMessage" ), this
+			) );
 			table.rawPut( "throw", new LuanJavaFunction(
 				LuanException.class.getMethod( "throwThis" ), this
 			) );