diff core/src/luan/modules/BinaryLuan.java @ 509:e3b0846dc2ef

throw exception for invalid indexes of string, binary, or java
author Franklin Schmidt <fschmidt@gmail.com>
date Fri, 22 May 2015 02:02:49 -0600
parents 23a93c118042
children 2da0bcb979b5
line wrap: on
line diff
--- a/core/src/luan/modules/BinaryLuan.java	Thu May 21 20:20:54 2015 -0600
+++ b/core/src/luan/modules/BinaryLuan.java	Fri May 22 02:02:49 2015 -0600
@@ -6,11 +6,13 @@
 import luan.LuanFunction;
 import luan.LuanException;
 import luan.LuanMethod;
+import luan.LuanBit;
 
 
 public final class BinaryLuan {
 
-	public static Object __index(LuanState luan,final byte[] binary,Object key) throws LuanException {
+	public static Object __index(LuanBit bit,final byte[] binary,Object key) throws LuanException {
+		LuanState luan = bit.luan;
 		LuanTable mod = (LuanTable)PackageLuan.require(luan,"luan:Binary");
 		Object obj = mod.get(luan,key);
 		if( obj instanceof LuanFunction ) {
@@ -24,7 +26,10 @@
 				}
 			};
 		}
-		return null;
+		if( bit.el != null )
+			throw bit.exception( "invalid index ["+luan.toString(key)+"] for binary ("+bit.el.text()+")" ) ;
+		else
+			throw bit.exception( "invalid index ["+luan.toString(key)+"] for binary") ;
 	}
 
 	static int start(byte[] binary,int i) {