util/Error: new error passing library
Replaces GLib's GError.
This commit is contained in:
@@ -23,6 +23,7 @@
|
||||
#include "InputLegacy.hxx"
|
||||
#include "Song.hxx"
|
||||
#include "Tag.hxx"
|
||||
#include "util/Error.hxx"
|
||||
|
||||
#include <glib.h>
|
||||
|
||||
@@ -208,6 +209,7 @@ asx_open_stream(struct input_stream *is)
|
||||
char buffer[1024];
|
||||
size_t nbytes;
|
||||
bool success;
|
||||
Error error2;
|
||||
GError *error = NULL;
|
||||
|
||||
/* parse the ASX XML file */
|
||||
@@ -218,12 +220,11 @@ asx_open_stream(struct input_stream *is)
|
||||
|
||||
while (true) {
|
||||
nbytes = input_stream_lock_read(is, buffer, sizeof(buffer),
|
||||
&error);
|
||||
error2);
|
||||
if (nbytes == 0) {
|
||||
if (error != NULL) {
|
||||
if (error2.IsDefined()) {
|
||||
g_markup_parse_context_free(context);
|
||||
g_warning("%s", error->message);
|
||||
g_error_free(error);
|
||||
g_warning("%s", error2.GetMessage());
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@@ -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;
|
||||
}
|
||||
|
@@ -23,6 +23,7 @@
|
||||
#include "InputLegacy.hxx"
|
||||
#include "Song.hxx"
|
||||
#include "Tag.hxx"
|
||||
#include "util/Error.hxx"
|
||||
|
||||
#include <glib.h>
|
||||
|
||||
@@ -104,6 +105,7 @@ static struct playlist_provider *
|
||||
pls_open_stream(struct input_stream *is)
|
||||
{
|
||||
GError *error = NULL;
|
||||
Error error2;
|
||||
size_t nbytes;
|
||||
char buffer[1024];
|
||||
bool success;
|
||||
@@ -113,11 +115,10 @@ pls_open_stream(struct input_stream *is)
|
||||
|
||||
do {
|
||||
nbytes = input_stream_lock_read(is, buffer, sizeof(buffer),
|
||||
&error);
|
||||
error2);
|
||||
if (nbytes == 0) {
|
||||
if (error != NULL) {
|
||||
g_warning("%s", error->message);
|
||||
g_error_free(error);
|
||||
if (error2.IsDefined()) {
|
||||
g_warning("%s", error2.GetMessage());
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@@ -23,6 +23,7 @@
|
||||
#include "InputLegacy.hxx"
|
||||
#include "Song.hxx"
|
||||
#include "Tag.hxx"
|
||||
#include "util/Error.hxx"
|
||||
|
||||
#include <glib.h>
|
||||
|
||||
@@ -205,6 +206,7 @@ rss_open_stream(struct input_stream *is)
|
||||
char buffer[1024];
|
||||
size_t nbytes;
|
||||
bool success;
|
||||
Error error2;
|
||||
GError *error = NULL;
|
||||
|
||||
/* parse the RSS XML file */
|
||||
@@ -215,12 +217,11 @@ rss_open_stream(struct input_stream *is)
|
||||
|
||||
while (true) {
|
||||
nbytes = input_stream_lock_read(is, buffer, sizeof(buffer),
|
||||
&error);
|
||||
error2);
|
||||
if (nbytes == 0) {
|
||||
if (error != NULL) {
|
||||
if (error2.IsDefined()) {
|
||||
g_markup_parse_context_free(context);
|
||||
g_warning("%s", error->message);
|
||||
g_error_free(error);
|
||||
g_warning("%s", error2.GetMessage());
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@@ -24,6 +24,7 @@
|
||||
#include "InputLegacy.hxx"
|
||||
#include "Song.hxx"
|
||||
#include "Tag.hxx"
|
||||
#include "util/Error.hxx"
|
||||
|
||||
#include <glib.h>
|
||||
#include <yajl/yajl_parse.h>
|
||||
@@ -244,18 +245,15 @@ static int
|
||||
soundcloud_parse_json(const char *url, yajl_handle hand,
|
||||
Mutex &mutex, Cond &cond)
|
||||
{
|
||||
struct input_stream *input_stream;
|
||||
GError *error = NULL;
|
||||
char buffer[4096];
|
||||
unsigned char *ubuffer = (unsigned char *)buffer;
|
||||
size_t nbytes;
|
||||
|
||||
input_stream = input_stream_open(url, mutex, cond, &error);
|
||||
Error error;
|
||||
input_stream *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 -1;
|
||||
}
|
||||
|
||||
@@ -266,12 +264,13 @@ soundcloud_parse_json(const char *url, yajl_handle hand,
|
||||
int done = 0;
|
||||
|
||||
while (!done) {
|
||||
nbytes = input_stream_read(input_stream, buffer, sizeof(buffer), &error);
|
||||
const size_t nbytes =
|
||||
input_stream_read(input_stream, buffer, sizeof(buffer),
|
||||
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)) {
|
||||
done = true;
|
||||
} else {
|
||||
|
@@ -22,6 +22,7 @@
|
||||
#include "MemoryPlaylistProvider.hxx"
|
||||
#include "InputLegacy.hxx"
|
||||
#include "Tag.hxx"
|
||||
#include "util/Error.hxx"
|
||||
|
||||
#include <glib.h>
|
||||
|
||||
@@ -224,6 +225,7 @@ xspf_open_stream(struct input_stream *is)
|
||||
char buffer[1024];
|
||||
size_t nbytes;
|
||||
bool success;
|
||||
Error error2;
|
||||
GError *error = NULL;
|
||||
|
||||
/* parse the XSPF XML file */
|
||||
@@ -234,12 +236,11 @@ xspf_open_stream(struct input_stream *is)
|
||||
|
||||
while (true) {
|
||||
nbytes = input_stream_lock_read(is, buffer, sizeof(buffer),
|
||||
&error);
|
||||
error2);
|
||||
if (nbytes == 0) {
|
||||
if (error != NULL) {
|
||||
if (error2.IsDefined()) {
|
||||
g_markup_parse_context_free(context);
|
||||
g_warning("%s", error->message);
|
||||
g_error_free(error);
|
||||
g_warning("%s", error2.GetMessage());
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user