Main: throw exception instead of calling FatalError()

This commit is contained in:
Max Kellermann 2018-08-19 23:13:29 +02:00
parent bd32a11016
commit 9999914c74

View File

@ -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,7 +284,7 @@ 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 "
throw FormatRuntimeError("buffer size \"%s\" is not a "
"positive integer, line %i",
param->value.c_str(), param->line);
buffer_size = tmp * KILOBYTE;
@ -302,7 +301,7 @@ 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",
throw FormatRuntimeError("buffer size \"%lu\" is too big",
(unsigned long)buffer_size);
float perc;
@ -311,7 +310,7 @@ 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 "
throw FormatRuntimeError("buffered before play \"%s\" is not "
"a positive percentage and less "
"than 100 percent, line %i",
param->value.c_str(), param->line);
@ -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