diff options
author | Max Kellermann <max@musicpd.org> | 2018-08-19 23:13:29 +0200 |
---|---|---|
committer | Max Kellermann <max@musicpd.org> | 2018-08-19 23:13:29 +0200 |
commit | 9999914c740aed91f39f6b53ca78e6081d9ccdd4 (patch) | |
tree | 3d8add1c4edc55f580848829bb09ab44eff53525 | |
parent | bd32a11016818765ca716b3eb66637d80ce336b1 (diff) |
Main: throw exception instead of calling FatalError()
-rw-r--r-- | src/Main.cxx | 21 |
1 files changed, 10 insertions, 11 deletions
diff --git a/src/Main.cxx b/src/Main.cxx index ad160b2ae..e7d7a6db0 100644 --- a/src/Main.cxx +++ b/src/Main.cxx @@ -48,7 +48,6 @@ #include "AudioParser.hxx" #include "pcm/PcmConvert.hxx" #include "unix/SignalHandlers.hxx" -#include "system/FatalError.hxx" #include "thread/Slack.hxx" #include "net/Init.hxx" #include "lib/icu/Init.hxx" @@ -285,9 +284,9 @@ initialize_decoder_and_player(const ConfigData &config, char *test; long tmp = strtol(param->value.c_str(), &test, 10); if (*test != '\0' || tmp <= 0 || tmp == LONG_MAX) - FormatFatalError("buffer size \"%s\" is not a " - "positive integer, line %i", - param->value.c_str(), param->line); + throw FormatRuntimeError("buffer size \"%s\" is not a " + "positive integer, line %i", + param->value.c_str(), param->line); buffer_size = tmp * KILOBYTE; if (buffer_size < MIN_BUFFER_SIZE) { @@ -302,8 +301,8 @@ initialize_decoder_and_player(const ConfigData &config, const unsigned buffered_chunks = buffer_size / CHUNK_SIZE; if (buffered_chunks >= 1 << 15) - FormatFatalError("buffer size \"%lu\" is too big", - (unsigned long)buffer_size); + throw FormatRuntimeError("buffer size \"%lu\" is too big", + (unsigned long)buffer_size); float perc; param = config.GetParam(ConfigOption::BUFFER_BEFORE_PLAY); @@ -311,10 +310,10 @@ initialize_decoder_and_player(const ConfigData &config, char *test; perc = strtod(param->value.c_str(), &test); if (*test != '%' || perc < 0 || perc > 100) { - FormatFatalError("buffered before play \"%s\" is not " - "a positive percentage and less " - "than 100 percent, line %i", - param->value.c_str(), param->line); + throw FormatRuntimeError("buffered before play \"%s\" is not " + "a positive percentage and less " + "than 100 percent, line %i", + param->value.c_str(), param->line); } if (perc > 80) { @@ -620,7 +619,7 @@ mpd_main_after_fork(const ConfigData &raw_config, const Config &config) database */ unsigned job = instance->update->Enqueue("", true); if (job == 0) - FatalError("directory update failed"); + throw std::runtime_error("directory update failed"); } #endif |