-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: optimize main function; proper error handling
- Loading branch information
Showing
2 changed files
with
16 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,15 @@ | ||
use crate::tailscale; | ||
use crate::tray::menu::SysTray; | ||
use std::error::Error; | ||
|
||
pub fn start_tray_service() { | ||
// start the tray service | ||
let _handle = ksni::spawn(SysTray { | ||
ctx: tailscale::status::get_current_status() | ||
.expect("Failed to update Tailscale status! Is Tailscale daemon running?"), | ||
}) | ||
.unwrap_or_else(|e| { | ||
panic!("Failed to start the tray service: {}", e); | ||
}); | ||
type TrayServiceError = Box<dyn Error>; | ||
|
||
pub fn start_tray_service() -> Result<(), TrayServiceError> { | ||
let status = tailscale::status::get_current_status() | ||
.map_err(|e| format!("Failed to update Tailscale status: {}", e))?; | ||
|
||
let _handle = ksni::spawn(SysTray { ctx: status }) | ||
.map_err(|e| format!("Failed to spawn Tray implementation: {}", e))?; | ||
|
||
Ok(()) | ||
} |