diff src/luan/LuanException.java @ 1335:e0cf0d108a77

major cleanup
author Franklin Schmidt <fschmidt@gmail.com>
date Thu, 14 Feb 2019 03:10:45 -0700
parents 25746915a241
children 221eedb0f54e
line wrap: on
line diff
--- a/src/luan/LuanException.java	Tue Feb 12 22:53:57 2019 -0700
+++ b/src/luan/LuanException.java	Thu Feb 14 03:10:45 2019 -0700
@@ -5,10 +5,13 @@
 import java.io.PrintStream;
 import java.util.List;
 import java.util.ArrayList;
+import java.util.Map;
+import java.util.HashMap;
 
 
 public final class LuanException extends Exception implements LuanCloneable {
 	private LuanTable table;
+	private Map extra = new HashMap();
 
 	public LuanException(String msg,Throwable cause) {
 		super(msg,cause);
@@ -29,13 +32,26 @@
 	@Override public void deepenClone(LuanCloneable dc,LuanCloner cloner) {
 		LuanException clone = (LuanException)dc;
 		clone.table = (LuanTable)cloner.clone(table);
+		clone.extra = (Map)cloner.clone(extra);
+	}
+
+	public void put(String key,Object value) throws LuanException {
+		if( table == null ) {
+			extra.put(key,value);
+		} else {
+			table.put(key,value);
+		}
 	}
 
 	public LuanTable table(Luan luan) {
 		if( table==null ) {
 			try {
 				LuanTable Boot = (LuanTable)luan.require("luan:Boot.luan");
-				table = (LuanTable)Boot.call( "new_error_table", this );
+				table = (LuanTable)Boot.fn("new_error_table").call(this );
+				for( Object stupid : extra.entrySet() ) {
+					Map.Entry entry = (Map.Entry)stupid;
+					table.put( entry.getKey(), entry.getValue() );
+				}
 			} catch(LuanException e) {
 				throw new RuntimeException(e);
 			}