Main: throw exception instead of calling FatalError()
This commit is contained in:
parent
bd32a11016
commit
9999914c74
21
src/Main.cxx
21
src/Main.cxx
@ -48,7 +48,6 @@
|
|||||||
#include "AudioParser.hxx"
|
#include "AudioParser.hxx"
|
||||||
#include "pcm/PcmConvert.hxx"
|
#include "pcm/PcmConvert.hxx"
|
||||||
#include "unix/SignalHandlers.hxx"
|
#include "unix/SignalHandlers.hxx"
|
||||||
#include "system/FatalError.hxx"
|
|
||||||
#include "thread/Slack.hxx"
|
#include "thread/Slack.hxx"
|
||||||
#include "net/Init.hxx"
|
#include "net/Init.hxx"
|
||||||
#include "lib/icu/Init.hxx"
|
#include "lib/icu/Init.hxx"
|
||||||
@ -285,9 +284,9 @@ initialize_decoder_and_player(const ConfigData &config,
|
|||||||
char *test;
|
char *test;
|
||||||
long tmp = strtol(param->value.c_str(), &test, 10);
|
long tmp = strtol(param->value.c_str(), &test, 10);
|
||||||
if (*test != '\0' || tmp <= 0 || tmp == LONG_MAX)
|
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",
|
"positive integer, line %i",
|
||||||
param->value.c_str(), param->line);
|
param->value.c_str(), param->line);
|
||||||
buffer_size = tmp * KILOBYTE;
|
buffer_size = tmp * KILOBYTE;
|
||||||
|
|
||||||
if (buffer_size < MIN_BUFFER_SIZE) {
|
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;
|
const unsigned buffered_chunks = buffer_size / CHUNK_SIZE;
|
||||||
|
|
||||||
if (buffered_chunks >= 1 << 15)
|
if (buffered_chunks >= 1 << 15)
|
||||||
FormatFatalError("buffer size \"%lu\" is too big",
|
throw FormatRuntimeError("buffer size \"%lu\" is too big",
|
||||||
(unsigned long)buffer_size);
|
(unsigned long)buffer_size);
|
||||||
|
|
||||||
float perc;
|
float perc;
|
||||||
param = config.GetParam(ConfigOption::BUFFER_BEFORE_PLAY);
|
param = config.GetParam(ConfigOption::BUFFER_BEFORE_PLAY);
|
||||||
@ -311,10 +310,10 @@ initialize_decoder_and_player(const ConfigData &config,
|
|||||||
char *test;
|
char *test;
|
||||||
perc = strtod(param->value.c_str(), &test);
|
perc = strtod(param->value.c_str(), &test);
|
||||||
if (*test != '%' || perc < 0 || perc > 100) {
|
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 "
|
"a positive percentage and less "
|
||||||
"than 100 percent, line %i",
|
"than 100 percent, line %i",
|
||||||
param->value.c_str(), param->line);
|
param->value.c_str(), param->line);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (perc > 80) {
|
if (perc > 80) {
|
||||||
@ -620,7 +619,7 @@ mpd_main_after_fork(const ConfigData &raw_config, const Config &config)
|
|||||||
database */
|
database */
|
||||||
unsigned job = instance->update->Enqueue("", true);
|
unsigned job = instance->update->Enqueue("", true);
|
||||||
if (job == 0)
|
if (job == 0)
|
||||||
FatalError("directory update failed");
|
throw std::runtime_error("directory update failed");
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user