From 169ea381385893610fd9c43a58bf1ef3c3bb2899 Mon Sep 17 00:00:00 2001 From: krolxon Date: Tue, 14 May 2024 12:00:13 +0530 Subject: [PATCH] handle if mpd server is not running --- src/connection.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/connection.rs b/src/connection.rs index 7afb3d2..f98310d 100755 --- a/src/connection.rs +++ b/src/connection.rs @@ -25,7 +25,10 @@ pub struct Connection { impl Connection { /// Create a new connection pub fn new(addrs: &str) -> Result { - let mut conn = Client::connect(addrs).unwrap(); + let mut conn = Client::connect(addrs).unwrap_or_else(|_| { + eprintln!("Error connecting to mpd server, Make sure mpd is running"); + std::process::exit(1); + }); let empty_song = Song { file: "No Song playing or in Queue".to_string(),