comparison src/luan/LuanException.java @ 1122:e15be31cee92

remove LuanException.getFullMessage()
author Franklin Schmidt <fschmidt@gmail.com>
date Mon, 14 Aug 2017 17:00:37 -0600
parents 4cf541886663
children 442abdfff437
comparison
equal deleted inserted replaced
1121:4cf541886663 1122:e15be31cee92
45 LuanException.class.getMethod( "getMessage" ), this 45 LuanException.class.getMethod( "getMessage" ), this
46 ) ); 46 ) );
47 table.rawPut( "throw", new LuanJavaFunction( 47 table.rawPut( "throw", new LuanJavaFunction(
48 LuanException.class.getMethod( "throwThis" ), this 48 LuanException.class.getMethod( "throwThis" ), this
49 ) ); 49 ) );
50 table.rawPut( "get_stack_trace_string", new LuanJavaFunction(
51 LuanException.class.getMethod( "getLuanStackTraceString" ), this
52 ) );
50 table.rawPut( "get_java_stack_trace_string", new LuanJavaFunction( 53 table.rawPut( "get_java_stack_trace_string", new LuanJavaFunction(
51 LuanException.class.getMethod( "getJavaStackTraceString" ), this 54 LuanException.class.getMethod( "getJavaStackTraceString" ), this
52 ) ); 55 ) );
53 metatable.rawPut( "__to_string", new LuanJavaFunction( 56 metatable.rawPut( "__to_string", new LuanJavaFunction(
54 LuanException.class.getMethod( "__to_string", LuanTable.class ), this 57 LuanException.class.getMethod( "__to_string", LuanTable.class ), this
63 public void throwThis() throws LuanException { 66 public void throwThis() throws LuanException {
64 throw this; 67 throw this;
65 } 68 }
66 69
67 public String __to_string(LuanTable ignore) { 70 public String __to_string(LuanTable ignore) {
68 return getFullMessage();
69 }
70
71 public String getFullMessage() {
72 return getLuanStackTraceString(); 71 return getLuanStackTraceString();
73 // return getLuanStackTraceString()+"\n"+getJavaStackTraceString();
74 /*
75 StringBuilder buf = new StringBuilder();
76
77 Object msg = table.rawGet("message");
78 String msgStr = (String)table.rawGet("message_string");
79 buf.append( msgStr );
80
81 for( int i = table.rawLength(); i>=1; i-- ) {
82 LuanTable tbl = (LuanTable)table.rawGet(i);
83 buf.append( "\n\t" ).append( tbl.rawGet("source") ).append( " line " ).append( tbl.rawGet("line") );
84 Object callTo = tbl.rawGet("call_to");
85 if( callTo != null )
86 buf.append( " in call to '" ).append( callTo ).append( "'" );
87 }
88
89 if( msg instanceof Throwable ) {
90 buf.append( "\nCaused by: " );
91 Throwable cause = (Throwable)msg;
92 StringWriter sw = new StringWriter();
93 cause.printStackTrace(new PrintWriter(sw));
94 buf.append( sw );
95 }
96
97 return buf.toString();
98 */
99 } 72 }
100 73
101 public String getJavaStackTraceString() { 74 public String getJavaStackTraceString() {
102 return getJavaStackTraceString(this); 75 return getJavaStackTraceString(this);
103 } 76 }