Mercurial Hosting > luan
diff core/src/luan/LuanException.java @ 531:f99c79b0b426
change LuanException.getFullMessage() to not require LuanState
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Wed, 27 May 2015 22:01:40 -0600 |
parents | 8dcf9e12446b |
children | f1601a4ce1aa |
line wrap: on
line diff
--- a/core/src/luan/LuanException.java Wed May 27 21:50:44 2015 -0600 +++ b/core/src/luan/LuanException.java Wed May 27 22:01:40 2015 -0600 @@ -13,8 +13,9 @@ LuanException(LuanBit bit,Object msg) throws LuanException { this( bit.luan.toString(msg), msg instanceof Throwable ? (Throwable)msg : null ); - table.rawPut("java",this); - table.rawPut("message",msg); + table.rawPut( "java", this ); + table.rawPut( "message", msg ); + table.rawPut( "message_string", bit.luan.toString(msg) ); for( StackTraceElement ste : bit.stackTrace() ) { LuanTable tbl = new LuanTable(); tbl.rawPut( "source", ste.call.source.name ); @@ -29,7 +30,7 @@ LuanException.class.getMethod( "throwThis" ), this ) ); metatable.rawPut( "__to_string", new LuanJavaFunction( - LuanException.class.getMethod( "__to_string", LuanState.class, LuanTable.class ), null + LuanException.class.getMethod( "__to_string", LuanTable.class ), null ) ); } catch(NoSuchMethodException e) { throw new RuntimeException(e); @@ -53,19 +54,16 @@ throw this; } - public String getFullMessage(LuanState luan) { - try { - return __to_string(luan,table); - } catch(LuanException e) { - throw new RuntimeException(e); - } + public String getFullMessage() { + return __to_string(table); } - public static String __to_string(LuanState luan,LuanTable table) throws LuanException { + public static String __to_string(LuanTable table) { StringBuilder buf = new StringBuilder(); Object msg = table.rawGet("message"); - buf.append( luan.toString(msg) ); + String msgStr = (String)table.rawGet("message_string"); + buf.append( msgStr ); for( int i = table.rawLength(); i>=1; i-- ) { LuanTable tbl = (LuanTable)table.rawGet(i);