Skip to content

runtime: return false from include() when the file fails, instead of rethrowing - #94

Merged
ResurrectedTrader merged 2 commits into
mainfrom
runtime-include-returns-false
Oct 8, 2026
Merged

ResurrectedTrader merged 2 commits into
mainfrom
runtime-include-returns-false

Conversation

@ResurrectedTrader

Copy link
Copy Markdown
Owner

d2bs behaviour

Script::Include (Script.cpp) compiles and executes the file. When either step fails it calls JS_ReportPendingException, which reports the error and clears it, and returns false. my_include (JSCore.cpp) hands that bool back to the script. A failing include never throws into the caller.

d2bsng before

Script::Include reported the exception, then called tryCatch.ReThrow() in both the compile-failure and the run-failure paths. The error went up into the calling script, and include() threw instead of returning false.

Fix

Drop both ReThrow() calls. The error is still reported through ReportException, which includes the QuitOnError handling, and include() returns false, as in d2bs. The binding's @returns doc now says so.

kolbot usage restored

libs/core/Loader.js loads each configured script with if (!include("scripts/" + script + ".js")) { Misc.errorReport(...); continue; }. With the rethrow, one broken script file threw out of the loader loop and ended the run. Now it is reported and skipped.

Not live-tested. It builds, and the unit tests and the format check pass.

🤖 Generated with Claude Code

@ResurrectedTrader

Copy link
Copy Markdown
Owner Author

Can we put this behind compatibility flag. Default to on, feels like a silent failure is a sad behaviour

ResurrectedTrader and others added 2 commits October 8, 2026 11:50
…rethrowing

An include that failed to compile or threw was reported and then rethrown
into the caller. d2bs reports the error, clears it and returns false, and
scripts are written around that return value.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…urnsFalse flag

The flag is on by default, so a failing include reports the error and
returns false, as d2bs did. A script that wants failures to surface turns
it off with Compatibility.set and gets the error rethrown into the caller.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@ResurrectedTrader
ResurrectedTrader force-pushed the runtime-include-returns-false branch from 93405a7 to 6763e5f Compare October 8, 2026 10:54
@ResurrectedTrader

Copy link
Copy Markdown
Owner Author

Done: the behaviour is now the includeReturnsFalse compatibility flag, on by default. On: a failing include (compile error or a throw) is reported and include() returns false, as d2bs did. Off (Compatibility.set("includeReturnsFalse", false)): the error is reported and rethrown into the caller, as before this PR. It is checked live in Script::Include, documented in the flag catalog and in docs/compatibility.md, and the include() doc mentions it. Rebased onto main.

@ResurrectedTrader
ResurrectedTrader merged commit dc330ad into main Oct 8, 2026
1 check passed
@ResurrectedTrader
ResurrectedTrader deleted the runtime-include-returns-false branch October 8, 2026 19:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant