configuration: show meaningful error message if MPD_PORT is not a number

master
Andrzej Rybczak 9 years ago
parent 6a3c49e8e6
commit 8dde3944ee
  1. 10
      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<int>(env_port));
{
try {
Mpd.SetPort(boost::lexical_cast<int>(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.

Loading…
Cancel
Save