comparison src/luan/LuaJavaFunction.java @ 40:e3624b7cd603

implement stack trace git-svn-id: https://luan-java.googlecode.com/svn/trunk@41 21e917c8-12df-6dd8-5cb6-c86387c605b9
author fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
date Fri, 21 Dec 2012 10:45:54 +0000
parents 8a57ebfdfd78
children 80b67b1a653c
comparison
equal deleted inserted replaced
39:e5bcb1eeafc1 40:e3624b7cd603
38 38
39 public Class<?>[] getParameterTypes() { 39 public Class<?>[] getParameterTypes() {
40 return method.getParameterTypes(); 40 return method.getParameterTypes();
41 } 41 }
42 42
43 @Override public Object[] call(LuaState lua,Object... args) { 43 @Override public Object[] call(LuaState lua,Object[] args) throws LuaException {
44 args = fixArgs(lua,args); 44 args = fixArgs(lua,args);
45 Object rtn; 45 Object rtn;
46 try { 46 try {
47 rtn = method.invoke(obj,args); 47 rtn = method.invoke(obj,args);
48 } catch(IllegalAccessException e) { 48 } catch(IllegalAccessException e) {
49 throw new RuntimeException(e); 49 throw new RuntimeException(e);
50 } catch(InvocationTargetException e) { 50 } catch(InvocationTargetException e) {
51 Throwable cause = e.getCause();
52 if( cause instanceof Error )
53 throw (Error)cause;
54 if( cause instanceof RuntimeException )
55 throw (RuntimeException)cause;
56 if( cause instanceof LuaException )
57 throw (LuaException)cause;
51 throw new RuntimeException(e); 58 throw new RuntimeException(e);
52 } catch(InstantiationException e) { 59 } catch(InstantiationException e) {
53 throw new RuntimeException(e); 60 throw new RuntimeException(e);
54 } 61 }
55 return rtnConverter.convert(rtn); 62 return rtnConverter.convert(rtn);