aboutsummaryrefslogtreecommitdiffstats
path: root/src/playlist/LastFMPlaylistPlugin.cxx
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2013-08-10 18:02:44 +0200
committerMax Kellermann <max@duempel.org>2013-09-04 18:14:22 +0200
commit29030b54c98b0aee65fbc10ebf7ba36bed98c02c (patch)
tree79766830b55ebca38ddbce84d8d548227eedb69e /src/playlist/LastFMPlaylistPlugin.cxx
parentc9fcc7f14860777458153eb2d13c773ccfa1daa2 (diff)
downloadmpd-29030b54c98b0aee65fbc10ebf7ba36bed98c02c.tar.gz
mpd-29030b54c98b0aee65fbc10ebf7ba36bed98c02c.tar.xz
mpd-29030b54c98b0aee65fbc10ebf7ba36bed98c02c.zip
util/Error: new error passing library
Replaces GLib's GError.
Diffstat (limited to 'src/playlist/LastFMPlaylistPlugin.cxx')
-rw-r--r--src/playlist/LastFMPlaylistPlugin.cxx35
1 files changed, 16 insertions, 19 deletions
diff --git a/src/playlist/LastFMPlaylistPlugin.cxx b/src/playlist/LastFMPlaylistPlugin.cxx
index a6071e092..5b168ee83 100644
--- a/src/playlist/LastFMPlaylistPlugin.cxx
+++ b/src/playlist/LastFMPlaylistPlugin.cxx
@@ -24,6 +24,7 @@
#include "conf.h"
#include "Song.hxx"
#include "InputLegacy.hxx"
+#include "util/Error.hxx"
#include <glib.h>
@@ -92,16 +93,14 @@ static char *
lastfm_get(const char *url, Mutex &mutex, Cond &cond)
{
struct input_stream *input_stream;
- GError *error = NULL;
+ Error error;
char buffer[4096];
- size_t length = 0, nbytes;
+ size_t length = 0;
- input_stream = input_stream_open(url, mutex, cond, &error);
+ input_stream = input_stream_open(url, mutex, cond, error);
if (input_stream == NULL) {
- if (error != NULL) {
- g_warning("%s", error->message);
- g_error_free(error);
- }
+ if (error.IsDefined())
+ g_warning("%s", error.GetMessage());
return NULL;
}
@@ -111,13 +110,12 @@ lastfm_get(const char *url, Mutex &mutex, Cond &cond)
input_stream_wait_ready(input_stream);
do {
- nbytes = input_stream_read(input_stream, buffer + length,
- sizeof(buffer) - length, &error);
+ size_t nbytes =
+ input_stream_read(input_stream, buffer + length,
+ sizeof(buffer) - length, error);
if (nbytes == 0) {
- if (error != NULL) {
- g_warning("%s", error->message);
- g_error_free(error);
- }
+ if (error.IsDefined())
+ g_warning("%s", error.GetMessage());
if (input_stream_eof(input_stream))
break;
@@ -166,7 +164,6 @@ lastfm_find(const char *response, const char *name)
static struct playlist_provider *
lastfm_open_uri(const char *uri, Mutex &mutex, Cond &cond)
{
- GError *error = NULL;
char *p, *q, *response, *session;
/* handshake */
@@ -225,15 +222,15 @@ lastfm_open_uri(const char *uri, Mutex &mutex, Cond &cond)
NULL);
g_free(session);
- const auto is = input_stream_open(p, mutex, cond, &error);
+ Error error;
+ const auto is = input_stream_open(p, mutex, cond, error);
g_free(p);
if (is == nullptr) {
- if (error != NULL) {
+ if (error.IsDefined())
g_warning("Failed to load XSPF playlist: %s",
- error->message);
- g_error_free(error);
- } else
+ error.GetMessage());
+ else
g_warning("Failed to load XSPF playlist");
return NULL;
}