Skip to content

Improve error handling in home directory resolution #33

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 16, 2025
Merged

Conversation

corylanou
Copy link
Member

This PR improves error handling when resolving paths that contain the tilde (~) character for home directory expansion. Previously, the homeDirectory() function would log and exit the program if it failed to get the user's home directory. Now it properly returns the error to the caller, allowing for more graceful error handling.

Key changes:

  • Modified homeDirectory() to return an error instead of calling log.Fatal()
  • Updated the calling code in Execute() to handle potential errors
  • Removed unused log import

These changes follow the Go best practice of propagating errors up the call stack rather than terminating the program at the point of failure, giving the caller more control over error handling.

@corylanou corylanou merged commit dd8eb4d into main Apr 16, 2025
@corylanou corylanou deleted the hd-with-error branch April 16, 2025 19:03
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.

2 participants