Skip to content

Refactor ErrorCode to use Result pattern and safe exit code mapping - #45

Merged
z80020100 merged 3 commits into
mainfrom
refactor/error-code-result-pattern
Mar 15, 2026
Merged

z80020100 merged 3 commits into
mainfrom
refactor/error-code-result-pattern

Conversation

@z80020100

Copy link
Copy Markdown
Owner

Summary

  • Remove Success variant from ErrorCode enum — error types should not represent success
  • Replace unsafe #[repr(u8)] discriminant access with explicit as_u8() match
  • Remove PartialEq/Eq/Termination impls that are no longer needed
  • Change main() to return ExitCode and logger.reconfig() to return Result<(), ErrorCode>
  • Add strum::EnumCount derive with tests verifying all exit codes are non-zero, unique, and ≤ 125

Closes #37

Test plan

  • cargo build passes
  • cargo fmt --all -- --check passes
  • cargo clippy passes with no warnings
  • cargo test passes

@z80020100 z80020100 self-assigned this Mar 15, 2026
@z80020100
z80020100 merged commit 55d2583 into main Mar 15, 2026
3 checks passed
@z80020100
z80020100 deleted the refactor/error-code-result-pattern branch March 15, 2026 04:07
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.

Improve ErrorCode design: Success variant and unsafe discriminant

1 participant