aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Makefile.am3
-rw-r--r--src/AudioConfig.cxx6
-rw-r--r--src/CommandLine.cxx4
-rw-r--r--src/ConfigData.cxx1
-rw-r--r--src/ConfigGlobal.cxx17
-rw-r--r--src/DecoderList.cxx6
-rw-r--r--src/Log.cxx6
-rw-r--r--src/Permission.cxx12
-rw-r--r--src/PlaylistRegistry.cxx6
-rw-r--r--src/ReplayGainConfig.cxx22
-rw-r--r--src/Tag.cxx6
-rw-r--r--src/Win32Main.cxx9
-rw-r--r--src/ZeroconfAvahi.cxx4
-rw-r--r--src/decoder/MikmodDecoderPlugin.cxx6
-rw-r--r--src/fs/Path.cxx4
-rw-r--r--src/mpd_error.h37
-rw-r--r--src/output/ShoutOutputPlugin.cxx6
-rw-r--r--src/system/FatalError.cxx6
-rw-r--r--src/system/FatalError.hxx4
19 files changed, 69 insertions, 96 deletions
diff --git a/Makefile.am b/Makefile.am
index 6def54a3a..b39848c59 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -66,8 +66,7 @@ mpd_headers = \
src/replay_gain_info.h \
src/TimePrint.cxx src/TimePrint.hxx \
src/stats.h \
- src/Timer.hxx \
- src/mpd_error.h
+ src/Timer.hxx
src_mpd_SOURCES = \
$(mpd_headers) \
diff --git a/src/AudioConfig.cxx b/src/AudioConfig.cxx
index bb4bdfd65..aa09c374f 100644
--- a/src/AudioConfig.cxx
+++ b/src/AudioConfig.cxx
@@ -24,8 +24,8 @@
#include "ConfigData.hxx"
#include "ConfigGlobal.hxx"
#include "ConfigOption.hxx"
-#include "mpd_error.h"
#include "util/Error.hxx"
+#include "system/FatalError.hxx"
static AudioFormat configured_audio_format;
@@ -47,6 +47,6 @@ void initAudioConfig(void)
Error error;
if (!audio_format_parse(configured_audio_format, param->value,
true, error))
- MPD_ERROR("error parsing line %i: %s",
- param->line, error.GetMessage());
+ FormatFatalError("error parsing line %i: %s",
+ param->line, error.GetMessage());
}
diff --git a/src/CommandLine.cxx b/src/CommandLine.cxx
index 9fb388751..ad5a20441 100644
--- a/src/CommandLine.cxx
+++ b/src/CommandLine.cxx
@@ -30,11 +30,11 @@
#include "InputPlugin.hxx"
#include "PlaylistRegistry.hxx"
#include "PlaylistPlugin.hxx"
-#include "mpd_error.h"
#include "fs/Path.hxx"
#include "fs/FileSystem.hxx"
#include "util/Error.hxx"
#include "util/Domain.hxx"
+#include "system/FatalError.hxx"
#ifdef ENABLE_ENCODER
#include "EncoderList.hxx"
@@ -185,7 +185,7 @@ parse_cmdline(int argc, char **argv, struct options *options,
g_option_context_free(context);
if (!ret)
- MPD_ERROR("option parsing failed: %s\n", gerror->message);
+ FatalError("option parsing failed", gerror);
if (option_version)
version();
diff --git a/src/ConfigData.cxx b/src/ConfigData.cxx
index 84a726799..f255e3488 100644
--- a/src/ConfigData.cxx
+++ b/src/ConfigData.cxx
@@ -24,7 +24,6 @@
#include "util/Error.hxx"
#include "fs/Path.hxx"
#include "system/FatalError.hxx"
-#include "mpd_error.h"
#include <glib.h>
diff --git a/src/ConfigGlobal.cxx b/src/ConfigGlobal.cxx
index 07c5ddd96..11e53fc3c 100644
--- a/src/ConfigGlobal.cxx
+++ b/src/ConfigGlobal.cxx
@@ -25,7 +25,7 @@
#include "ConfigPath.hxx"
#include "fs/Path.hxx"
#include "util/Error.hxx"
-#include "mpd_error.h"
+#include "system/FatalError.hxx"
#include <glib.h>
@@ -125,8 +125,8 @@ config_get_unsigned(ConfigOption option, unsigned default_value)
value = strtol(param->value, &endptr, 0);
if (*endptr != 0 || value < 0)
- MPD_ERROR("Not a valid non-negative number in line %i",
- param->line);
+ FormatFatalError("Not a valid non-negative number in line %i",
+ param->line);
return (unsigned)value;
}
@@ -143,10 +143,11 @@ config_get_positive(ConfigOption option, unsigned default_value)
value = strtol(param->value, &endptr, 0);
if (*endptr != 0)
- MPD_ERROR("Not a valid number in line %i", param->line);
+ FormatFatalError("Not a valid number in line %i", param->line);
if (value <= 0)
- MPD_ERROR("Not a positive number in line %i", param->line);
+ FormatFatalError("Not a positive number in line %i",
+ param->line);
return (unsigned)value;
}
@@ -162,9 +163,9 @@ config_get_bool(ConfigOption option, bool default_value)
success = get_bool(param->value, &value);
if (!success)
- MPD_ERROR("Expected boolean value (yes, true, 1) or "
- "(no, false, 0) on line %i\n",
- param->line);
+ FormatFatalError("Expected boolean value (yes, true, 1) or "
+ "(no, false, 0) on line %i\n",
+ param->line);
return value;
}
diff --git a/src/DecoderList.cxx b/src/DecoderList.cxx
index 092c3dca9..fd80514dd 100644
--- a/src/DecoderList.cxx
+++ b/src/DecoderList.cxx
@@ -22,7 +22,6 @@
#include "DecoderPlugin.hxx"
#include "ConfigGlobal.hxx"
#include "ConfigData.hxx"
-#include "mpd_error.h"
#include "decoder/AudiofileDecoderPlugin.hxx"
#include "decoder/PcmDecoderPlugin.hxx"
#include "decoder/DsdiffDecoderPlugin.hxx"
@@ -43,6 +42,7 @@
#include "decoder/ModplugDecoderPlugin.hxx"
#include "decoder/MpcdecDecoderPlugin.hxx"
#include "decoder/FluidsynthDecoderPlugin.hxx"
+#include "system/FatalError.hxx"
#include <glib.h>
@@ -204,8 +204,8 @@ decoder_plugin_config(const char *plugin_name)
while ((param = config_get_next_param(CONF_DECODER, param)) != NULL) {
const char *name = param->GetBlockValue("plugin");
if (name == NULL)
- MPD_ERROR("decoder configuration without 'plugin' name in line %d",
- param->line);
+ FormatFatalError("decoder configuration without 'plugin' name in line %d",
+ param->line);
if (strcmp(name, plugin_name) == 0)
return param;
diff --git a/src/Log.cxx b/src/Log.cxx
index 721e59862..869327d25 100644
--- a/src/Log.cxx
+++ b/src/Log.cxx
@@ -26,9 +26,9 @@
#include "system/FatalError.hxx"
#include "fs/Path.hxx"
#include "fs/FileSystem.hxx"
-#include "mpd_error.h"
#include "util/Error.hxx"
#include "util/Domain.hxx"
+#include "system/FatalError.hxx"
#include <assert.h>
#include <sys/types.h>
@@ -230,8 +230,8 @@ parse_log_level(const char *value, unsigned line)
else if (0 == strcmp(value, "verbose"))
return G_LOG_LEVEL_DEBUG;
else {
- MPD_ERROR("unknown log level \"%s\" at line %u\n",
- value, line);
+ FormatFatalError("unknown log level \"%s\" at line %u",
+ value, line);
return G_LOG_LEVEL_MESSAGE;
}
}
diff --git a/src/Permission.cxx b/src/Permission.cxx
index 6f8782324..258ace60a 100644
--- a/src/Permission.cxx
+++ b/src/Permission.cxx
@@ -22,7 +22,7 @@
#include "ConfigData.hxx"
#include "ConfigGlobal.hxx"
#include "ConfigOption.hxx"
-#include "mpd_error.h"
+#include "system/FatalError.hxx"
#include <map>
#include <string>
@@ -64,7 +64,7 @@ static unsigned parsePermissions(const char *string)
} else if (strcmp(temp, PERMISSION_ADMIN_STRING) == 0) {
permission |= PERMISSION_ADMIN;
} else {
- MPD_ERROR("unknown permission \"%s\"", temp);
+ FormatFatalError("unknown permission \"%s\"", temp);
}
}
@@ -92,10 +92,10 @@ void initPermissions(void)
strchr(param->value, PERMISSION_PASSWORD_CHAR);
if (separator == NULL)
- MPD_ERROR("\"%c\" not found in password string "
- "\"%s\", line %i",
- PERMISSION_PASSWORD_CHAR,
- param->value, param->line);
+ FormatFatalError("\"%c\" not found in password string "
+ "\"%s\", line %i",
+ PERMISSION_PASSWORD_CHAR,
+ param->value, param->line);
password = g_strndup(param->value,
separator - param->value);
diff --git a/src/PlaylistRegistry.cxx b/src/PlaylistRegistry.cxx
index 88628e455..d2692e06f 100644
--- a/src/PlaylistRegistry.cxx
+++ b/src/PlaylistRegistry.cxx
@@ -37,7 +37,7 @@
#include "util/Error.hxx"
#include "ConfigGlobal.hxx"
#include "ConfigData.hxx"
-#include "mpd_error.h"
+#include "system/FatalError.hxx"
#include <assert.h>
#include <string.h>
@@ -87,8 +87,8 @@ playlist_plugin_config(const char *plugin_name)
while ((param = config_get_next_param(CONF_PLAYLIST_PLUGIN, param)) != NULL) {
const char *name = param->GetBlockValue("name");
if (name == NULL)
- MPD_ERROR("playlist configuration without 'plugin' name in line %d",
- param->line);
+ FormatFatalError("playlist configuration without 'plugin' name in line %d",
+ param->line);
if (strcmp(name, plugin_name) == 0)
return param;
diff --git a/src/ReplayGainConfig.cxx b/src/ReplayGainConfig.cxx
index a921d2130..3442628b3 100644
--- a/src/ReplayGainConfig.cxx
+++ b/src/ReplayGainConfig.cxx
@@ -23,7 +23,7 @@
#include "ConfigData.hxx"
#include "ConfigGlobal.hxx"
#include "Playlist.hxx"
-#include "mpd_error.h"
+#include "system/FatalError.hxx"
#include <glib.h>
@@ -86,8 +86,8 @@ void replay_gain_global_init(void)
const struct config_param *param = config_get_param(CONF_REPLAYGAIN);
if (param != NULL && !replay_gain_set_mode_string(param->value)) {
- MPD_ERROR("replaygain value \"%s\" at line %i is invalid\n",
- param->value, param->line);
+ FormatFatalError("replaygain value \"%s\" at line %i is invalid\n",
+ param->value, param->line);
}
param = config_get_param(CONF_REPLAYGAIN_PREAMP);
@@ -97,13 +97,13 @@ void replay_gain_global_init(void)
float f = strtod(param->value, &test);
if (*test != '\0') {
- MPD_ERROR("Replaygain preamp \"%s\" is not a number at "
- "line %i\n", param->value, param->line);
+ FormatFatalError("Replaygain preamp \"%s\" is not a number at "
+ "line %i\n", param->value, param->line);
}
if (f < -15 || f > 15) {
- MPD_ERROR("Replaygain preamp \"%s\" is not between -15 and"
- "15 at line %i\n", param->value, param->line);
+ FormatFatalError("Replaygain preamp \"%s\" is not between -15 and"
+ "15 at line %i\n", param->value, param->line);
}
replay_gain_preamp = pow(10, f / 20.0);
@@ -116,13 +116,13 @@ void replay_gain_global_init(void)
float f = strtod(param->value, &test);
if (*test != '\0') {
- MPD_ERROR("Replaygain missing preamp \"%s\" is not a number at "
- "line %i\n", param->value, param->line);
+ FormatFatalError("Replaygain missing preamp \"%s\" is not a number at "
+ "line %i\n", param->value, param->line);
}
if (f < -15 || f > 15) {
- MPD_ERROR("Replaygain missing preamp \"%s\" is not between -15 and"
- "15 at line %i\n", param->value, param->line);
+ FormatFatalError("Replaygain missing preamp \"%s\" is not between -15 and"
+ "15 at line %i\n", param->value, param->line);
}
replay_gain_missing_preamp = pow(10, f / 20.0);
diff --git a/src/Tag.cxx b/src/Tag.cxx
index 228db1a66..c960da537 100644
--- a/src/Tag.cxx
+++ b/src/Tag.cxx
@@ -24,7 +24,7 @@
#include "ConfigGlobal.hxx"
#include "ConfigOption.hxx"
#include "Song.hxx"
-#include "mpd_error.h"
+#include "system/FatalError.hxx"
#include <glib.h>
#include <assert.h>
@@ -119,8 +119,8 @@ void tag_lib_init(void)
type = tag_name_parse_i(c);
if (type == TAG_NUM_OF_ITEM_TYPES)
- MPD_ERROR("error parsing metadata item \"%s\"",
- c);
+ FormatFatalError("error parsing metadata item \"%s\"",
+ c);
ignore_tag_items[type] = false;
diff --git a/src/Win32Main.cxx b/src/Win32Main.cxx
index d495fe088..03be38db6 100644
--- a/src/Win32Main.cxx
+++ b/src/Win32Main.cxx
@@ -23,8 +23,8 @@
#ifdef WIN32
#include "gcc.h"
-#include "mpd_error.h"
#include "GlobalEvents.hxx"
+#include "system/FatalError.hxx"
#include <cstdlib>
#include <atomic>
@@ -92,8 +92,8 @@ service_main(gcc_unused DWORD argc, gcc_unused CHAR *argv[])
if (service_handle == 0) {
error_code = GetLastError();
error_message = g_win32_error_message(error_code);
- MPD_ERROR("RegisterServiceCtrlHandlerEx() failed: %s",
- error_message);
+ FormatFatalError("RegisterServiceCtrlHandlerEx() failed: %s",
+ error_message);
}
service_notify_status(SERVICE_START_PENDING);
@@ -150,7 +150,8 @@ int win32_main(int argc, char *argv[])
}
error_message = g_win32_error_message(error_code);
- MPD_ERROR("StartServiceCtrlDispatcher() failed: %s", error_message);
+ FormatFatalError("StartServiceCtrlDispatcher() failed: %s",
+ error_message);
}
void win32_app_started()
diff --git a/src/ZeroconfAvahi.cxx b/src/ZeroconfAvahi.cxx
index 2d7a9fee9..8d26c75f6 100644
--- a/src/ZeroconfAvahi.cxx
+++ b/src/ZeroconfAvahi.cxx
@@ -22,7 +22,7 @@
#include "ZeroconfInternal.hxx"
#include "Listen.hxx"
#include "event/Loop.hxx"
-#include "mpd_error.h"
+#include "system/FatalError.hxx"
#include <glib.h>
@@ -225,7 +225,7 @@ AvahiInit(EventLoop &loop, const char *serviceName)
g_debug("Initializing interface");
if (!avahi_is_valid_service_name(serviceName))
- MPD_ERROR("Invalid zeroconf_name \"%s\"", serviceName);
+ FormatFatalError("Invalid zeroconf_name \"%s\"", serviceName);
avahiName = avahi_strdup(serviceName);
diff --git a/src/decoder/MikmodDecoderPlugin.cxx b/src/decoder/MikmodDecoderPlugin.cxx
index f9896ef98..0de876f06 100644
--- a/src/decoder/MikmodDecoderPlugin.cxx
+++ b/src/decoder/MikmodDecoderPlugin.cxx
@@ -20,8 +20,8 @@
#include "config.h"
#include "MikmodDecoderPlugin.hxx"
#include "DecoderAPI.hxx"
-#include "mpd_error.h"
#include "TagHandler.hxx"
+#include "system/FatalError.hxx"
#include <glib.h>
#include <mikmod.h>
@@ -112,8 +112,8 @@ mikmod_decoder_init(const config_param &param)
mikmod_sample_rate = param.GetBlockValue("sample_rate", 44100u);
if (!audio_valid_sample_rate(mikmod_sample_rate))
- MPD_ERROR("Invalid sample rate in line %d: %u",
- param.line, mikmod_sample_rate);
+ FormatFatalError("Invalid sample rate in line %d: %u",
+ param.line, mikmod_sample_rate);
md_device = 0;
md_reverb = 0;
diff --git a/src/fs/Path.cxx b/src/fs/Path.cxx
index 71e71a78b..7de19a582 100644
--- a/src/fs/Path.cxx
+++ b/src/fs/Path.cxx
@@ -20,7 +20,7 @@
#include "config.h"
#include "fs/Path.hxx"
#include "ConfigGlobal.hxx"
-#include "mpd_error.h"
+#include "system/FatalError.hxx"
#include "gcc.h"
#include <glib.h>
@@ -105,7 +105,7 @@ SetFSCharset(const char *charset)
assert(charset != NULL);
if (!IsSupportedCharset(charset))
- MPD_ERROR("invalid filesystem charset: %s", charset);
+ FormatFatalError("invalid filesystem charset: %s", charset);
fs_charset = charset;
diff --git a/src/mpd_error.h b/src/mpd_error.h
deleted file mode 100644
index f7af84656..000000000
--- a/src/mpd_error.h
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Copyright (C) 2003-2011 The Music Player Daemon Project
- * http://www.musicpd.org
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-
-#ifndef MPD_ERROR_H
-#define MPD_ERROR_H
-
-#include <glib.h>
-#include <stdlib.h>
-
-/* This macro is used as an intermediate step to a proper error handling
- * using #Error in mpd. It is used for unrecoverable error conditions
- * and exits immediately. The long-term goal is to replace this macro by
- * proper error handling. */
-
-#define MPD_ERROR(...) \
- do { \
- g_critical(__VA_ARGS__); \
- exit(EXIT_FAILURE); \
- } while(0)
-
-#endif
diff --git a/src/output/ShoutOutputPlugin.cxx b/src/output/ShoutOutputPlugin.cxx
index 82b61f7c8..fe271141f 100644
--- a/src/output/ShoutOutputPlugin.cxx
+++ b/src/output/ShoutOutputPlugin.cxx
@@ -25,7 +25,7 @@
#include "ConfigError.hxx"
#include "util/Error.hxx"
#include "util/Domain.hxx"
-#include "mpd_error.h"
+#include "system/FatalError.hxx"
#include <shout/shout.h>
#include <glib.h>
@@ -102,8 +102,8 @@ require_block_string(const config_param &param, const char *name)
{
const char *value = param.GetBlockValue(name);
if (value == nullptr)
- MPD_ERROR("no \"%s\" defined for shout device defined at line " \
- "%i\n", name, param.line);
+ FormatFatalError("no \"%s\" defined for shout device defined "
+ "at line %u\n", name, param.line);
return value;
}
diff --git a/src/system/FatalError.cxx b/src/system/FatalError.cxx
index 65cb9aa26..7c0dc942a 100644
--- a/src/system/FatalError.cxx
+++ b/src/system/FatalError.cxx
@@ -61,6 +61,12 @@ FatalError(const Error &error)
}
void
+FatalError(const char *msg, const Error &error)
+{
+ FormatFatalError("%s: %s", msg, error.GetMessage());
+}
+
+void
FatalError(GError *error)
{
FatalError(error->message);
diff --git a/src/system/FatalError.hxx b/src/system/FatalError.hxx
index be67aabbd..03baf66c4 100644
--- a/src/system/FatalError.hxx
+++ b/src/system/FatalError.hxx
@@ -43,6 +43,10 @@ FatalError(const Error &error);
gcc_noreturn
void
+FatalError(const char *msg, const Error &error);
+
+gcc_noreturn
+void
FatalError(GError *error);
gcc_noreturn