Error Handling
Pathmaster is designed to handle errors gracefully and provide clear, helpful error messages. This guide explains common errors you might encounter and how to resolve them.
Common Error Types
Permission Errors
Error: Permission denied when modifying /etc/bin
Cause: You’re trying to add a directory that requires elevated permissions.
Solution:
For system directories, use sudo:
sudo pathmaster add /opt/special/binAdd user-level directories instead (~/.local/bin) when possible
Invalid Path Errors
Error: Directory does not exist: /home/user/nonexistent
Cause: You’re trying to add a directory that doesn’t exist.
Solution:
Create the directory first:
mkdir -p /path/to/directoryCheck for typos in the path
Use tab-completion to avoid path errors
Shell Configuration Errors
Error: Could not update shell configuration file ~/.bashrc
Cause: Pathmaster couldn’t modify your shell configuration file.
Solution:
Check file permissions:
ls -la ~/.bashrcEnsure the file exists:
touch ~/.bashrcManually update your PATH if needed
Restore Errors
Error: No backup found with timestamp 20250401120000
Cause: You’re trying to restore from a backup that doesn’t exist.
Solution:
List available backups:
pathmaster historyChoose an existing timestamp
Use the most recent backup if unsure:
pathmaster restore
How Pathmaster Handles Errors
Pathmaster follows these principles for error handling:
Safety First: Pathmaster creates backups before making changes
Validation: Directories are validated before being added to PATH
Rollback: If an error occurs during an operation, pathmaster tries to roll back changes
Clear Messages: Error messages include specific details about what went wrong
Exit Codes: Pathmaster returns non-zero exit codes on error for script integration
Debugging Techniques
When encountering persistent issues:
Check PATH: Run
pathmaster listto see current PATH entriesCheck Invalid Entries: Run
pathmaster checkto identify invalid directoriesReview Backups: Run
pathmaster historyto see backup historyRestore if Needed: Run
pathmaster restoreto revert to a known good stateCheck Shell Config: Examine your shell configuration file for issues
Error Exit Codes
Pathmaster uses the following exit codes:
0: Success
1: General error
2: Invalid input or usage
3: Permission denied
4: Resource not found
Best Practices
Always have a backup strategy beyond pathmaster’s automatic backups
Check your PATH occasionally with
pathmaster checkFlush invalid paths periodically with
pathmaster flushKeep a simple, clean PATH to avoid conflicts