Skip to content

fix: add exit code for error handling#45

Merged
zu1k merged 1 commit intozu1k:masterfrom
ZureTz:ZureTz
Jul 3, 2025
Merged

fix: add exit code for error handling#45
zu1k merged 1 commit intozu1k:masterfrom
ZureTz:ZureTz

Conversation

@ZureTz
Copy link
Copy Markdown
Contributor

@ZureTz ZureTz commented Jun 5, 2025

This commit makes it convenient for shell script to determine whether the login/logout process finished successfully or not. Without this, the shell would always assume that the process exits successfully (with code 0).

This commit makes it convenient for shell script to determine whether the login/logout process finished successfully or not. Without this, the shell would always assume that the process exits successfully (with code 0).
@zu1k zu1k merged commit 8bf9b51 into zu1k:master Jul 3, 2025
2 checks passed
@zu1k
Copy link
Copy Markdown
Owner

zu1k commented Jul 3, 2025

Thank you!

@zu1k zu1k requested a review from Copilot July 3, 2025 13:10
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR enhances the CLI’s error handling by directing error messages to stderr and exiting with a non-zero code when operations fail.

  • Switched println! to eprintln! for all error outputs
  • Added process::exit(1) after each error to set an exit status
  • Combined std::env and std::process imports and reordered srun imports
Comments suppressed due to low confidence (2)

src/main.rs:60

  • [nitpick] Consider making this message more descriptive and consistent with other errors, e.g., eprintln!("Error parsing arguments: {}", e);.
            eprintln!("parse args error: {}", e);

src/main.rs:159

  • [nitpick] It would be helpful to add a test for this error path to ensure the CLI exits with a non-zero status when the config file cannot be read.
            eprintln!("read config file error: {}", e);

Comment thread src/main.rs
Comment on lines +60 to +61
eprintln!("parse args error: {}", e);
process::exit(1);
Copy link

Copilot AI Jul 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are many duplicated eprintln! + process::exit(1) sequences; consider extracting them into a helper function like fn exit_error(msg: &str).

Suggested change
eprintln!("parse args error: {}", e);
process::exit(1);
exit_error(&format!("parse args error: {}", e));

Copilot uses AI. Check for mistakes.
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.

3 participants