mpd_error.h: remove obsolete header
Migrate the remaining callers to FatalError().
This commit is contained in:
parent
3330aa6f6a
commit
7a4c9f5f4c
|
@ -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) \
|
||||
|
|
|
@ -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());
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -24,7 +24,6 @@
|
|||
#include "util/Error.hxx"
|
||||
#include "fs/Path.hxx"
|
||||
#include "system/FatalError.hxx"
|
||||
#include "mpd_error.h"
|
||||
|
||||
#include <glib.h>
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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 ¶m)
|
|||
|
||||
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;
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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
|
|
@ -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 ¶m, 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;
|
||||
}
|
||||
|
|
|
@ -60,6 +60,12 @@ FatalError(const Error &error)
|
|||
FatalError(error.GetMessage());
|
||||
}
|
||||
|
||||
void
|
||||
FatalError(const char *msg, const Error &error)
|
||||
{
|
||||
FormatFatalError("%s: %s", msg, error.GetMessage());
|
||||
}
|
||||
|
||||
void
|
||||
FatalError(GError *error)
|
||||
{
|
||||
|
|
|
@ -41,6 +41,10 @@ gcc_noreturn
|
|||
void
|
||||
FatalError(const Error &error);
|
||||
|
||||
gcc_noreturn
|
||||
void
|
||||
FatalError(const char *msg, const Error &error);
|
||||
|
||||
gcc_noreturn
|
||||
void
|
||||
FatalError(GError *error);
|
||||
|
|
Loading…
Reference in New Issue