rmptui169ea38
handle if mpd server is not running
+4 −1
1 file changed
- M src/connection.rs +4 −1
| @@ -25,7 +25,10 @@ pub struct Connection { | |||
| 25 | 25 | impl Connection { | |
| 26 | 26 | /// Create a new connection | |
| 27 | 27 | pub fn new(addrs: &str) -> Result<Self> { | |
| 28 | − | let mut conn = Client::connect(addrs).unwrap(); | |
| 28 | + | let mut conn = Client::connect(addrs).unwrap_or_else(|_| { | |
| 29 | + | eprintln!("Error connecting to mpd server, Make sure mpd is running"); | |
| 30 | + | std::process::exit(1); | |
| 31 | + | }); | |
| 29 | 32 | ||
| 30 | 33 | let empty_song = Song { | |
| 31 | 34 | file: "No Song playing or in Queue".to_string(), | |