-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Description
Summary
run_batch() calls std::process::exit(1) on query failure instead of returning an error, even though the function signature is Result<()>.
Affected code
src/main.rs(run_batch, error branch in query loop)
Why this is a problem
- Breaks function contract:
run_batchis modeled as fallible (Result) but exits process directly. - Skips normal drop/unwind path:
process::exitbypasses standard Rust cleanup semantics. - Prevents centralized error handling: caller (
main) cannot intercept/format/classify batch errors consistently. - Hurts composability/testability: impossible to reuse
run_batchsafely from other call sites.
Current behavior
Inside run_batch query loop:
- on
Err(e)fromexecute_sql_to_strings, it prints error and callsstd::process::exit(1).
Proposed fix
- Replace direct process exit with error propagation:
return Err(anyhow::anyhow!("Error executing query: {}", e));
- Let top-level
mainown process exit policy.
Optional follow-up
- Add a
--keep-goingmode for file-based multi-statement execution if desired.
Test coverage to add
- Batch file with one valid and one invalid statement:
- verify non-zero process exit at top-level
- verify error message
- verify no hard exit inside
run_batch
- Ensure error propagation path is exercised from
main.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels