From 8dde3944ee1878a7f26dd24bfe5e31f4e72c05b1 Mon Sep 17 00:00:00 2001 From: Andrzej Rybczak Date: Wed, 16 Nov 2016 11:12:56 +0100 Subject: [PATCH] configuration: show meaningful error message if MPD_PORT is not a number --- src/configuration.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/configuration.cpp b/src/configuration.cpp index b21887b..d6c364c 100644 --- a/src/configuration.cpp +++ b/src/configuration.cpp @@ -177,7 +177,15 @@ bool configure(int argc, char **argv) if (env_host != nullptr) Mpd.SetHostname(env_host); if (env_port != nullptr) - Mpd.SetPort(boost::lexical_cast(env_port)); + { + try { + Mpd.SetPort(boost::lexical_cast(env_port)); + } catch (boost::bad_lexical_cast &) { + throw std::runtime_error("MPD_PORT environment variable (" + + std::string(env_port) + + ") is not a number"); + } + } // if MPD connection details are provided as command line // parameters, use them as their priority is the highest. -- 2.11.4.GIT