diff options
author | Max Kellermann <max@duempel.org> | 2013-08-10 18:02:44 +0200 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2013-09-04 18:14:22 +0200 |
commit | 29030b54c98b0aee65fbc10ebf7ba36bed98c02c (patch) | |
tree | 79766830b55ebca38ddbce84d8d548227eedb69e /test/DumpDatabase.cxx | |
parent | c9fcc7f14860777458153eb2d13c773ccfa1daa2 (diff) | |
download | mpd-29030b54c98b0aee65fbc10ebf7ba36bed98c02c.tar.gz mpd-29030b54c98b0aee65fbc10ebf7ba36bed98c02c.tar.xz mpd-29030b54c98b0aee65fbc10ebf7ba36bed98c02c.zip |
util/Error: new error passing library
Replaces GLib's GError.
Diffstat (limited to 'test/DumpDatabase.cxx')
-rw-r--r-- | test/DumpDatabase.cxx | 30 |
1 files changed, 13 insertions, 17 deletions
diff --git a/test/DumpDatabase.cxx b/test/DumpDatabase.cxx index e788d625a..cf86d91ff 100644 --- a/test/DumpDatabase.cxx +++ b/test/DumpDatabase.cxx @@ -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; } |