feat: deterministic exit codes per error category#91
Merged
Conversation
Adds stable, scriptable exit codes so callers can programmatically distinguish failure modes: 0 - Success 1 - General / unknown (catch-all) 2 - CLI / usage error (invalid args, unknown format) 3 - I/O error (file not found, permission denied) 4 - Format / parse error (malformed input data) 5 - Mapping error (evaluation failure) 6 - Value error (type mismatch, overflow) Changes: - Add exit_code module with named constants to error.rs - Add MorphError::exit_code() method mapping each variant to its code - Update main.rs to use e.exit_code() instead of hardcoded 1 - Add unit tests for exit code correctness and uniqueness - Add integration tests (tests/exit_codes.rs) verifying each code via the CLI binary Fixes #85
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Implements deterministic, user-facing exit codes so callers can programmatically distinguish failure modes. Previously all errors exited with code 1.
Exit Code Table
Changes
src/error.rs: Addedexit_codemodule with named constants andMorphError::exit_code()method that maps each error variant to its codesrc/main.rs: Updated to usee.exit_code()instead of hardcodedprocess::exit(1)tests/exit_codes.rs: Integration tests verifying each exit code via the CLI binary (success, CLI errors, I/O errors, format errors, mapping errors, determinism)Fixes #85