util/Error: new error passing library

Replaces GLib's GError.
This commit is contained in:
Max Kellermann
2013-08-10 18:02:44 +02:00
parent c9fcc7f148
commit 29030b54c9
256 changed files with 3269 additions and 3371 deletions
Makefile.am
src
AllCommands.cxxArchiveFile.hxxArchivePlugin.cxxArchivePlugin.hxxAudioConfig.cxxAudioParser.cxxAudioParser.hxxCheckAudioFormat.cxxCheckAudioFormat.hxxClientEvent.cxxClientFile.cxxClientFile.hxxClientInternal.hxxClientNew.cxxClientProcess.cxxCommandError.cxxCommandError.hxxCommandLine.cxxCommandLine.hxxConfigData.cxxConfigData.hxxConfigError.cxxConfigError.hxxConfigFile.cxxConfigFile.hxxConfigGlobal.cxxConfigGlobal.hxxConfigPath.cxxConfigPath.hxxDatabaseCommands.cxxDatabaseError.cxxDatabaseError.hxxDatabaseGlue.cxxDatabaseGlue.hxxDatabaseHelpers.cxxDatabaseHelpers.hxxDatabasePlaylist.cxxDatabasePlaylist.hxxDatabasePlugin.hxxDatabasePrint.cxxDatabasePrint.hxxDatabaseQueue.cxxDatabaseQueue.hxxDatabaseSave.cxxDatabaseSave.hxxDatabaseSimple.hxxDatabaseVisitor.hxxDecoderAPI.cxxDecoderControl.hxxDecoderError.cxxDecoderError.hxxDecoderThread.cxxDirectory.cxxDirectory.hxxDirectorySave.cxxDirectorySave.hxxEncoderPlugin.hxxFilterConfig.cxxFilterConfig.hxxFilterInternal.hxxFilterPlugin.cxxFilterPlugin.hxxInotifySource.cxxInotifySource.hxxInotifyUpdate.cxxInputInit.cxxInputInit.hxxInputLegacy.hxxInputPlugin.hxxInputStream.cxxListen.cxxListen.hxxLog.cxxLog.hxxMain.cxxMapper.hxxMixerAll.cxxMixerControl.cxxMixerControl.hxxMixerPlugin.hxxOtherCommands.cxxOutputAll.cxxOutputAll.hxxOutputControl.cxxOutputError.cxxOutputError.hxxOutputInit.cxxOutputInternal.hxxOutputPlugin.cxxOutputPlugin.hxxOutputThread.cxxPlayerControl.cxxPlayerControl.hxxPlayerThread.cxxPlaylistAny.cxxPlaylistCommands.cxxPlaylistDatabase.cxxPlaylistDatabase.hxxPlaylistEdit.cxxPlaylistError.cxxPlaylistError.hxxPlaylistFile.cxxPlaylistFile.hxxPlaylistPrint.cxxPlaylistPrint.hxxPlaylistRegistry.cxxPlaylistSave.cxxPlaylistSave.hxxPlaylistSong.cxxQueueCommands.cxxQueueSave.cxxSongSave.cxxSongSave.hxxSongSticker.hxxSongUpdate.cxxStats.cxxStickerCommands.cxxStickerDatabase.cxxStickerDatabase.hxxTagFile.cxxTagId3.cxxTagId3.hxxTextInputStream.cxxUpdateArchive.cxxUpdateGlue.cxx
archive
db
decoder
encoder
event
filter
input
mixer
mpd_error.h
output
pcm
playlist
protocol
system
util
test

@ -27,6 +27,7 @@
#include "conf.h"
#include "Tag.hxx"
#include "fs/Path.hxx"
#include "util/Error.hxx"
#include <iostream>
using std::cout;
@ -46,14 +47,14 @@ my_log_func(const gchar *log_domain, gcc_unused GLogLevelFlags log_level,
}
static bool
DumpDirectory(const Directory &directory, GError **)
DumpDirectory(const Directory &directory, Error &)
{
cout << "D " << directory.path << endl;
return true;
}
static bool
DumpSong(Song &song, GError **)
DumpSong(Song &song, Error &)
{
cout << "S " << song.parent->path << "/" << song.uri << endl;
return true;
@ -61,7 +62,7 @@ DumpSong(Song &song, GError **)
static bool
DumpPlaylist(const PlaylistInfo &playlist,
const Directory &directory, GError **)
const Directory &directory, Error &)
{
cout << "P " << directory.path << "/" << playlist.name.c_str() << endl;
return true;
@ -70,8 +71,6 @@ DumpPlaylist(const PlaylistInfo &playlist,
int
main(int argc, char **argv)
{
GError *error = nullptr;
if (argc != 3) {
cerr << "Usage: DumpDatabase CONFIG PLUGIN" << endl;
return 1;
@ -98,9 +97,9 @@ main(int argc, char **argv)
config_global_init();
if (!ReadConfigFile(config_path, &error)) {
cerr << error->message << endl;
g_error_free(error);
Error error;
if (!ReadConfigFile(config_path, error)) {
cerr << error.GetMessage() << endl;
return EXIT_FAILURE;
}
@ -113,29 +112,26 @@ main(int argc, char **argv)
if (path != nullptr)
param.AddBlockParam("path", path->value, path->line);
Database *db = plugin->create(param, &error);
Database *db = plugin->create(param, error);
if (db == nullptr) {
cerr << error->message << endl;
g_error_free(error);
cerr << error.GetMessage() << endl;
return EXIT_FAILURE;
}
if (!db->Open(&error)) {
if (!db->Open(error)) {
delete db;
cerr << error->message << endl;
g_error_free(error);
cerr << error.GetMessage() << endl;
return EXIT_FAILURE;
}
const DatabaseSelection selection("", true);
if (!db->Visit(selection, DumpDirectory, DumpSong, DumpPlaylist,
&error)) {
error)) {
db->Close();
delete db;
cerr << error->message << endl;
g_error_free(error);
cerr << error.GetMessage() << endl;
return EXIT_FAILURE;
}