Skip to content

Show only the message when --js code fails to close #808 - #809

Merged
mathiasrw merged 1 commit into
mainfrom
fix/808
Oct 23, 2026
Merged

mathiasrw merged 1 commit into
mainfrom
fix/808

Conversation

@mathiasrw

@mathiasrw mathiasrw commented Oct 23, 2026 •

Copy link
Copy Markdown
Owner

Closes #808

Stacked on #807.

Change

When the code of --js fails, only the message is told, as a panic:

> echo -n foo | rexreplace o 'nope()' --js
 ❌ The code of --js failed for the piped data: ReferenceError: nope is not defined
    No further processing.

Before, the stack trace of the runtime showed all the code put in front of the code of the user (the numbers of #791 with their cousins), about a screen long.

  • It is a panic (exit code 3), as code that fails for one file most often fails for all. The files after it are not changed.
  • The message says which file, or the piped data.
  • It is the same for a syntax error and for an error when the code runs, once per file or once per match, in the sync and the async flow.
  • The error is in errors in the status report.

Also in this PR

The help for --simulate says: "Execute everything during a run except changes RexReplace would normally make to the file system. Code from --js still runs, and can change data even with --simulate." (This PR gave it another text. #838 changed it to this one.)

Tests

yarn test-ci passes: the demo on Node and Bun, and 1024 Bun tests. test/fix/808.test.js is new. Five tests expected the error of the code to come out of the engine, and now check the message and the exit code 3.

@mathiasrw
mathiasrw added this pull request to stack #787 October 23, 2026 09:45
@mathiasrw
mathiasrw force-pushed the fix/808 branch 5 times, most recently from c712c76 to 5af4b94 Compare October 23, 2026 10:11
@mathiasrw
mathiasrw marked this pull request as draft October 23, 2026 10:25
@mathiasrw
mathiasrw marked this pull request as ready for review October 23, 2026 10:26
@mathiasrw
mathiasrw marked this pull request as draft October 23, 2026 10:40
@mathiasrw
mathiasrw marked this pull request as ready for review October 23, 2026 10:42
@mathiasrw
mathiasrw force-pushed the fix/808 branch 4 times, most recently from 220bd70 to 53dfae6 Compare October 23, 2026 10:51
Base automatically changed from fix/796 to main October 23, 2026 10:51
@mathiasrw
mathiasrw merged commit eaebee3 into main Oct 23, 2026
7 checks passed
@mathiasrw
mathiasrw deleted the fix/808 branch October 23, 2026 11:01
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.

Show only the message when --js code fails

1 participant