Skip to content

fix: report output write failures as one sqlcj diagnostic - #36

Merged
omer-cengel merged 2 commits into
masterfrom
fix/output-write-failure-diagnostics
Sep 25, 2026
Merged

omer-cengel merged 2 commits into
masterfrom
fix/output-write-failure-diagnostics

Conversation

@omer-cengel

Copy link
Copy Markdown
Member

Summary

When sqlcj generate could not create an output directory or write a generated file, the failure escaped as an unhandled exception with a stack trace. It now ends the run with a single sqlcj: diagnostic naming the resolved path that could not be written, and exit status 1, matching how configuration and source failures are already reported.

Changes

  • Report Cannot create output directory: <path> when a generated file's parent directory cannot be created, and Cannot write generated file: <path> when the file itself cannot be written; both use the resolved path and keep the underlying filesystem exception as the cause.
  • Propagate these failures from the compiler as CompilationException, so the existing generate error handling prints one line and exits with status 1 without a stack trace.
  • Add tests at the writer, compiler, and CLI subprocess levels that force failures portably by placing a regular file where an output directory is needed and a directory where a generated file goes.
  • Document both diagnostics, the exit status, and that files already written by the failing run stay in place, in the configuration guide and README.

Scope and non-goals

  • Analysis still completes for every configured entry before the first file is written, and writing remains non-transactional: no rollback, staging directory, or stale-output cleanup is added.
  • The diagnostic names the failing path only; it does not add the filesystem's reason or a suggested correction.
  • Generated file content, write order, other diagnostics and their exit codes, and --config path resolution are unchanged.

@omer-cengel
omer-cengel merged commit 991476d into master Sep 25, 2026
6 checks passed
@omer-cengel
omer-cengel deleted the fix/output-write-failure-diagnostics branch September 25, 2026 19:58
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