File tree Expand file tree Collapse file tree 3 files changed +22
-7
lines changed
Expand file tree Collapse file tree 3 files changed +22
-7
lines changed Original file line number Diff line number Diff line change 1+ -cp src
2+ -cp test
3+ -debug
4+ -lib sourcemap
5+ -D JSTACK_FORMAT=vscode
6+
7+ extraParams.hxml
8+
9+ -main Test
10+ -js build/test.js
Original file line number Diff line number Diff line change @@ -24,7 +24,7 @@ class CallStack {
2424 for (site in callsites ) {
2525 if (wrapCallSite != null ) site = wrapCallSite (site );
2626 var method = null ;
27- var fullName : String = site .getFunctionName ();
27+ var fullName : String = site .getFunctionName ();
2828 if (fullName != null ) {
2929 var idx = fullName .lastIndexOf (" ." );
3030 if (idx >= 0 ) {
Original file line number Diff line number Diff line change @@ -40,13 +40,18 @@ class JStack {
4040 /**
4141 * Overwrite this method to handle uncaught exceptions manually.
4242 * Any returned value will be written to stderr.
43- * @param e - Uncaught exception.
43+ * @param e - Uncaught exception. It's `js.Error` most of the time,
44+ * but it also can be any other type if thrown outside of Haxe-generated code.
4445 */
4546 @:access (haxe. CallStack )
46- static public dynamic function uncaughtExceptionHandler (e : Error ) : String {
47- var stack = CallStack .getStack (e ).map (improveStackItem );
48- var error = e .message + CallStack .toString (stack ) + ' \n ' ;
49- return error ;
47+ static public dynamic function uncaughtExceptionHandler (e : Dynamic ) : String {
48+ if (untyped __js__ (" {0} instanceof Error" , e )) {
49+ var stack = CallStack .getStack (e ).map (improveStackItem );
50+ var error = e .message + CallStack .toString (stack ) + ' \n ' ;
51+ return error ;
52+ } else {
53+ return ' Uncaught exception: ' + Std .string (e );
54+ }
5055 }
5156
5257 function new () {
@@ -148,7 +153,7 @@ class JStack {
148153 * @param e -
149154 */
150155 static function _uncaughtExceptionHandler (e : Dynamic ) {
151- var error = uncaughtExceptionHandler (@ :privateAccess CallStack . lastException );
156+ var error = uncaughtExceptionHandler (e );
152157 if (error != null && error .length > 0 ) {
153158 untyped __js__ (' console.log({0})' , error );
154159 if (isNode ()) {
You can’t perform that action at this time.
0 commit comments