diff --git a/src/main/java/me/topchetoeu/jscript/runtime/Engine.java b/src/main/java/me/topchetoeu/jscript/runtime/Engine.java index 736b7fc..199bdcd 100644 --- a/src/main/java/me/topchetoeu/jscript/runtime/Engine.java +++ b/src/main/java/me/topchetoeu/jscript/runtime/Engine.java @@ -40,7 +40,7 @@ public final class Engine implements EventLoop { try { ((Task)task).notifier.complete(task.runnable.get()); } - catch (CancellationException e) { throw e; } + catch (CancellationException e) { task.notifier.cancel(false); throw e; } catch (RuntimeException e) { task.notifier.completeExceptionally(e); } } catch (InterruptedException | CancellationException e) { diff --git a/src/main/java/me/topchetoeu/jscript/runtime/Frame.java b/src/main/java/me/topchetoeu/jscript/runtime/Frame.java index 66e0c94..b051b24 100644 --- a/src/main/java/me/topchetoeu/jscript/runtime/Frame.java +++ b/src/main/java/me/topchetoeu/jscript/runtime/Frame.java @@ -213,7 +213,9 @@ public final class Frame { catch (StackOverflowError e) { throw STACK_OVERFLOW; } catch (EngineException e) { error = e; } catch (RuntimeException e) { - System.out.println(dbg.getMapOrEmpty(function).toLocation(codePtr, true)); + if (!(e instanceof CancellationException)) { + System.out.println(dbg.getMapOrEmpty(function).toLocation(codePtr, true)); + } throw e; } }