Skip to content

Propagate command exit code from Main - #259

Merged
opcfoundation-org merged 1 commit into
OPCFoundation:masterfrom
cailloumajor:fix/propagate-exit-code
Sep 28, 2026
Merged

opcfoundation-org merged 1 commit into
OPCFoundation:masterfrom
cailloumajor:fix/propagate-exit-code

Conversation

@cailloumajor

Copy link
Copy Markdown

Fixes #258

Problem

Main was declared as async Task and discarded the exit code returned by ModelCompilerApplication.Run(). System.CommandLine handles exceptions thrown by command actions (prints them to stderr, returns 1), but that code was lost, so the tool always exited with 0.

Change

  • Main now returns Task<int> and forwards the result of ModelCompilerApplication.Run(args).
  • The catch blocks return 3 instead of calling Environment.Exit(3) (same exit code).

Verification

Command Before After
compile -d2 /nonexistent.xml -o2 /tmp/out 0 1
compile --bogus (invalid option) — 1
--help — 0

🤖 Generated with Claude Code

Main was declared as `async Task` and discarded the value returned by
ModelCompilerApplication.Run(). System.CommandLine catches exceptions
thrown by command actions, prints them to stderr and returns a non-zero
code, but that code was lost, so the process always exited with 0.

Main now returns Task<int> and forwards the result. The catch blocks
return 3 instead of calling Environment.Exit(3), keeping the same code.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@CLAassistant

CLAassistant commented Sep 28, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

cailloumajor added a commit to cailloumajor/ua-nodeset-generator that referenced this pull request Sep 28, 2026
@opcfoundation-org
opcfoundation-org merged commit 163096c into OPCFoundation:master Sep 28, 2026
1 check passed
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.

Opc.Ua.ModelCompiler always exits with code 0, even when the command fails

3 participants