Revision: 4826
http://sourceforge.net/p/vexi/code/4826
Author: mkpg2
Date: 2015-11-10 15:52:57 +0000 (Tue, 10 Nov 2015)
Log Message:
-----------
Improve Debugging. Show thread name when catching unhandled exceptions.
Modified Paths:
--------------
branches/vexi3/org.vexi-library.js/src/main/java/org/ibex/js/JSU.java
branches/vexi3/org.vexi-library.js/src/main/java/org/ibex/js/Scheduler.java
branches/vexi3/org.vexi-library.js/src/main/java/org/ibex/js/Thread.java
branches/vexi3/org.vexi-library.js/src/poke/java/org/ibex/js/JSUX.java
Modified: branches/vexi3/org.vexi-library.js/src/main/java/org/ibex/js/JSU.java
===================================================================
--- branches/vexi3/org.vexi-library.js/src/main/java/org/ibex/js/JSU.java
2015-11-10 15:33:49 UTC (rev 4825)
+++ branches/vexi3/org.vexi-library.js/src/main/java/org/ibex/js/JSU.java
2015-11-10 15:52:57 UTC (rev 4826)
@@ -451,5 +451,22 @@
throw new JSExn("Unsupported charset: "+name+" -
"+e.getMessage());
}
}
+
+ static public String backtrace(Interpreter i) {
+ JSExn e = new JSExn("");
+ e.fillIfEmpty(i);
+ return backtrace(e);
+ }
+ static public String backtrace(JSExn e) {
+ StringBuilder r = new StringBuilder();
+ String msg = e.asObject().getMessage();
+ if(msg!=null)
+ r.append(msg+"\n");
+ for (int i=0; i < e.backtrace.size(); i++){
+ r.append(" at " + (String) e.backtrace.get(i));
+ r.append("\n");
+ }
+ return r.toString();
+ }
}
Modified:
branches/vexi3/org.vexi-library.js/src/main/java/org/ibex/js/Scheduler.java
===================================================================
--- branches/vexi3/org.vexi-library.js/src/main/java/org/ibex/js/Scheduler.java
2015-11-10 15:33:49 UTC (rev 4825)
+++ branches/vexi3/org.vexi-library.js/src/main/java/org/ibex/js/Scheduler.java
2015-11-10 15:52:57 UTC (rev 4826)
@@ -119,21 +119,22 @@
Log.uInfo(Scheduler.class, "Scheduler halted: " +
e.getMessage());
return;*/
} catch (Exception e) {
- // HACK for running tests, as we need to pass any
+ // REMARK for running tests, as we need to pass any
// uncaught js/assertion exceptions out.
if (quitOnExn) {
return e;
}
- // FIXME - are these messages always accurate(!) Could
look at current
- // task for more information
- if (e instanceof JSExn) {
- logger.error(Scheduler.class, "A JavaScript thread
spawned with vexi.thread threw an exception:");
- ((JSExn)e).printStackTrace(Logger.ERROR, logger,
Scheduler.class);
- } else {
- logger.error(Scheduler.class, "A Callable threw an
exception which was caught by the scheduler:");
- logger.error(Scheduler.class, e);
+ if(current instanceof Thread){
+ logger.error(Scheduler.class, "Vexiscript unhandled
exception - "+((Thread)current).description()+":");
+ }else{
+ logger.error(Scheduler.class, "Background call
unhandled exception:");
}
+ if(e instanceof JSExn){
+ ((JSExn)e).printStackTrace(Logger.ERROR, logger,
Scheduler.class);
+ }else{
+ logger.error(Scheduler.class, e);
+ }
}
// if an Error is thrown it will cause the engine to quit
}
Modified:
branches/vexi3/org.vexi-library.js/src/main/java/org/ibex/js/Thread.java
===================================================================
--- branches/vexi3/org.vexi-library.js/src/main/java/org/ibex/js/Thread.java
2015-11-10 15:33:49 UTC (rev 4825)
+++ branches/vexi3/org.vexi-library.js/src/main/java/org/ibex/js/Thread.java
2015-11-10 15:52:57 UTC (rev 4826)
@@ -87,7 +87,7 @@
faction.setJSThread(null);
}
}
- }
+ }
public String description() {
if (f!=null) {
@@ -96,16 +96,17 @@
if(thread_name!=null){
r += " - "+thread_name;
}
- if(currentInterpreter!=null){
- r += JSUX.backtrace(currentInterpreter);
- }
-
return r;
}
return type;
}
public String toString() {
- return description();
+ String r = description();
+ if(currentInterpreter!=null){
+ r += JSU.backtrace(currentInterpreter);
+ }
+ return r;
+
}
}
Modified: branches/vexi3/org.vexi-library.js/src/poke/java/org/ibex/js/JSUX.java
===================================================================
--- branches/vexi3/org.vexi-library.js/src/poke/java/org/ibex/js/JSUX.java
2015-11-10 15:33:49 UTC (rev 4825)
+++ branches/vexi3/org.vexi-library.js/src/poke/java/org/ibex/js/JSUX.java
2015-11-10 15:52:57 UTC (rev 4826)
@@ -24,24 +24,9 @@
return sw.toString();
}
- static public String backtrace(JSExn e) {
- StringBuilder r = new StringBuilder();
- String msg = e.asObject().getMessage();
- if(msg!=null)
- r.append(msg+"\n");
- for (int i=0; i < e.backtrace.size(); i++){
- r.append(" at " + (String) e.backtrace.get(i));
- r.append("\n");
- }
- return r.toString();
- }
+ static public String backtrace(JSExn e) { return JSU.backtrace(e); }
+ static public String backtrace(Interpreter i) { return
JSU.backtrace(i); }
- static public String backtrace(Interpreter i) {
- JSExn e = new JSExn("");
- e.fillIfEmpty(i);
- return backtrace(e);
- }
-
static public Object jsToDynamic(JS js) throws JSExn{
// VERIFY - can js send every type even if the value
// doesn't put it in that types range (double, but no
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
_______________________________________________
Vexi-svn mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/vexi-svn