Mercurial Hosting > luan
diff core/src/luan/LuanJavaFunction.java @ 646:cdc70de628b5
simplify LuanException
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Tue, 29 Mar 2016 19:58:39 -0600 |
parents | 60c549d43988 |
children |
line wrap: on
line diff
--- a/core/src/luan/LuanJavaFunction.java Tue Mar 29 18:09:51 2016 -0600 +++ b/core/src/luan/LuanJavaFunction.java Tue Mar 29 19:58:39 2016 -0600 @@ -70,19 +70,19 @@ @Override public Object call(LuanState luan,Object[] args) throws LuanException { try { args = fixArgs(luan,args); - return doCall(luan,args); + return doCall(args); } catch(IllegalArgumentException e) { - checkArgs(luan,args); + checkArgs(args); throw e; } } public Object rawCall(LuanState luan,Object[] args) throws LuanException { args = fixArgs(luan,args); - return doCall(luan,args); + return doCall(args); } - private Object doCall(LuanState luan,Object[] args) throws LuanException { + private Object doCall(Object[] args) throws LuanException { Object rtn; try { rtn = method.invoke(obj,args); @@ -94,7 +94,7 @@ throw (Error)cause; if( cause instanceof LuanException ) throw (LuanException)cause; - throw new LuanException(luan,cause); + throw new LuanException(cause); } catch(InstantiationException e) { throw new RuntimeException(e); } @@ -114,7 +114,7 @@ primitiveMap.put(Void.TYPE,Void.class); } - private void checkArgs(LuanState luan,Object[] args) throws LuanException { + private void checkArgs(Object[] args) throws LuanException { Class[] a = getParameterTypes(); int start = takesLuaState ? 1 : 0; for( int i=start; i<a.length; i++ ) { @@ -131,10 +131,10 @@ expected = fixType(paramType.getSimpleName()); if( arg==null ) { if( paramType.isPrimitive() ) - throw new LuanException(luan,"bad argument #"+(i+1-start)+" ("+expected+" expected, got nil)"); + throw new LuanException("bad argument #"+(i+1-start)+" ("+expected+" expected, got nil)"); } else { String got = fixType(arg.getClass().getSimpleName()); - throw new LuanException(luan,"bad argument #"+(i+1-start)+" ("+expected+" expected, got "+got+")"); + throw new LuanException("bad argument #"+(i+1-start)+" ("+expected+" expected, got "+got+")"); } } }