Skip to content

refactor(cli): improve error handling for remote script fetch#1408

Merged
antongolub merged 1 commit intogoogle:mainfrom
apoorvdarshan:fix/empty-catch-blocks
Feb 22, 2026
Merged

refactor(cli): improve error handling for remote script fetch#1408
antongolub merged 1 commit intogoogle:mainfrom
apoorvdarshan:fix/empty-catch-blocks

Conversation

@apoorvdarshan
Copy link
Contributor

@apoorvdarshan apoorvdarshan commented Feb 16, 2026

Ref #1394

// Before: process.exit(1) — abrupt, no error propagation
// After: throws Fail with descriptive message
await $`npx zx http://example.com/nonexistent.mjs`
// stderr: Error: Can't get http://...
//         Failed to fetch remote script: http://... (404)

@antongolub
Copy link
Collaborator

We'd like to avoid bloating comments, so the current try-catches are fine. But the explicit error related to fetch seems reasonable. I would only support this change.

@apoorvdarshan
Copy link
Contributor Author

@antongolub Thanks for the feedback! Scoped the PR to only the fetch error handling change in readScriptFromHttp — removed all the catch block comments.

@apoorvdarshan apoorvdarshan changed the title refactor: replace empty catch blocks with descriptive comments fix(cli): improve error handling for remote script fetch Feb 22, 2026
@antongolub antongolub changed the title fix(cli): improve error handling for remote script fetch refactor(cli): improve error handling for remote script fetch Feb 22, 2026
@antongolub antongolub added the refactoring Internal code improvements label Feb 22, 2026
@antongolub
Copy link
Collaborator

Follow the PR template hints:

  1. update bundles
  2. add/update autotests

@apoorvdarshan
Copy link
Contributor Author

@antongolub Updated — bundle rebuilt and added assertions to the existing scripts from https 500 test to verify the new Fail error message and exit code. Also updated the PR description to follow the template.

Replace abrupt process.exit(1) in readScriptFromHttp with
process.exitCode = 1 + throw new Fail(...) for consistent
error handling with the rest of the codebase.

Ref google#1394
@apoorvdarshan
Copy link
Contributor Author

@antongolub Squashed everything into a single clean commit rebased on latest main. Only the fetch error handling change remains — no catch block comments. Bundle and test updated.

@antongolub antongolub merged commit 11f1c8e into google:main Feb 22, 2026
30 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

refactoring Internal code improvements

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants