File tree Expand file tree Collapse file tree 2 files changed +16
-13
lines changed Expand file tree Collapse file tree 2 files changed +16
-13
lines changed Original file line number Diff line number Diff line change @@ -12,10 +12,11 @@ fn main() {
12
12
env_logger:: init ( ) ;
13
13
14
14
// start tray service
15
- start_tray_service ( ) ;
15
+ match start_tray_service ( ) {
16
+ Ok ( _) => println ! ( "Tray service started successfully." ) ,
17
+ Err ( e) => eprintln ! ( "Failed to start the tray service: {}" , e) ,
18
+ }
16
19
17
20
// keep the main thread alive
18
- loop {
19
- park ( ) ;
20
- }
21
+ park ( ) ;
21
22
}
Original file line number Diff line number Diff line change 1
1
use crate :: tailscale;
2
2
use crate :: tray:: menu:: SysTray ;
3
+ use std:: error:: Error ;
3
4
4
- pub fn start_tray_service ( ) {
5
- // start the tray service
6
- let _handle = ksni:: spawn ( SysTray {
7
- ctx : tailscale:: status:: get_current_status ( )
8
- . expect ( "Failed to update Tailscale status! Is Tailscale daemon running?" ) ,
9
- } )
10
- . unwrap_or_else ( |e| {
11
- panic ! ( "Failed to start the tray service: {}" , e) ;
12
- } ) ;
5
+ type TrayServiceError = Box < dyn Error > ;
6
+
7
+ pub fn start_tray_service ( ) -> Result < ( ) , TrayServiceError > {
8
+ let status = tailscale:: status:: get_current_status ( )
9
+ . map_err ( |e| format ! ( "Failed to update Tailscale status: {}" , e) ) ?;
10
+
11
+ let _handle = ksni:: spawn ( SysTray { ctx : status } )
12
+ . map_err ( |e| format ! ( "Failed to spawn Tray implementation: {}" , e) ) ?;
13
+
14
+ Ok ( ( ) )
13
15
}
You can’t perform that action at this time.
0 commit comments