summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: bd6d6b0)
raw | patch | inline | side by side (parent: bd6d6b0)
author | Max Kellermann <max@duempel.org> | |
Tue, 29 Sep 2009 16:21:38 +0000 (18:21 +0200) | ||
committer | Max Kellermann <max@duempel.org> | |
Tue, 29 Sep 2009 16:21:38 +0000 (18:21 +0200) |
Let mpd_connection_clear_error() decide if the error was fatal.
src/mpdclient.c | patch | blob | history |
diff --git a/src/mpdclient.c b/src/mpdclient.c
index c0d11afb47c6ea54e83b9544a5fa5a2419d68000..a688162a1832640f0938051d4b1a08afe90e6176 100644 (file)
--- a/src/mpdclient.c
+++ b/src/mpdclient.c
}
-/* Error callbacks */
-static gint
-error_cb(struct mpdclient *c, gint error, const gchar *msg)
-{
- GList *list = c->error_callbacks;
-
- if (list == NULL)
- fprintf(stderr, "error [%d]: %s\n", (error & 0xFF), msg);
-
- while (list) {
- mpdc_error_cb_t cb = list->data;
- if (cb)
- cb(c, error, msg);
- list = list->next;
- }
-
- mpd_connection_clear_error(c->connection);
- return error;
-}
-
-
/****************************************************************************/
/*** mpdclient functions ****************************************************/
/****************************************************************************/
mpdclient_handle_error(struct mpdclient *c)
{
enum mpd_error error = mpd_connection_get_error(c->connection);
- bool is_fatal = error != MPD_ERROR_SERVER;
assert(error != MPD_ERROR_SUCCESS);
if (error == MPD_ERROR_SERVER)
error = error | (mpd_connection_get_server_error(c->connection) << 8);
- error_cb(c, error, mpd_connection_get_error_message(c->connection));
+ for (GList *list = c->error_callbacks; list != NULL;
+ list = list->next) {
+ mpdc_error_cb_t cb = list->data;
+ cb(c, error, mpd_connection_get_error_message(c->connection));
+ }
- if (is_fatal)
+ if (!mpd_connection_clear_error(c->connection))
mpdclient_disconnect(c);
return error;
g_error("Out of memory");
if (mpd_connection_get_error(c->connection) != MPD_ERROR_SUCCESS) {
- retval = error_cb(c, mpd_connection_get_error(c->connection),
- mpd_connection_get_error_message(c->connection));
+ retval = mpdclient_handle_error(c);
if (retval != 0) {
mpd_connection_free(c->connection);
c->connection = NULL;