haimgel / display-switch

Turn a $30 USB switch into a full-featured multi-monitor KVM switch
https://haim.dev/posts/2020-07-28-dual-monitor-kvm/
MIT License
2.85k stars 112 forks source link

Return a Result from main() #36

Closed svend closed 3 years ago

svend commented 3 years ago

Change main to return a Result. Fatal errors can be propagated up to main, which will print the error message and exit with a failure code.

Update app to return errors instead of panicking.

Before:

19:29:12 [ERROR] Could not load configuration: configuration file "/Users/user/Library/Preferences/display-switch.ini" not found
thread 'main' panicked at 'Configuration error', src/app.rs:45:17
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

After:

Error: configuration file "/Users/user/Library/Preferences/display-switch.ini" not found