From 29030b54c98b0aee65fbc10ebf7ba36bed98c02c Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Sat, 10 Aug 2013 18:02:44 +0200 Subject: util/Error: new error passing library Replaces GLib's GError. --- src/system/SocketError.hxx | 36 ++++++++++++++---------------------- 1 file changed, 14 insertions(+), 22 deletions(-) (limited to 'src/system/SocketError.hxx') diff --git a/src/system/SocketError.hxx b/src/system/SocketError.hxx index 53a0c1d8f..c42e267dd 100644 --- a/src/system/SocketError.hxx +++ b/src/system/SocketError.hxx @@ -21,6 +21,7 @@ #define MPD_SOCKET_ERROR_HXX #include "gcc.h" +#include "util/Error.hxx" #include @@ -33,15 +34,10 @@ typedef int socket_error_t; #endif /** - * A GQuark for GError for socket I/O errors. The code is an errno + * A #Domain for #Error for socket I/O errors. The code is an errno * value (or WSAGetLastError() on Windows). */ -gcc_const -static inline GQuark -SocketErrorQuark(void) -{ - return g_quark_from_static_string("socket"); -} +extern const class Domain socket_domain; gcc_pure static inline socket_error_t @@ -121,33 +117,29 @@ public: }; static inline void -SetSocketError(GError **error_r, socket_error_t code) +SetSocketError(Error &error, socket_error_t code) { -#ifdef WIN32 - if (error_r == NULL) - return; -#endif - const SocketErrorMessage msg(code); - g_set_error_literal(error_r, SocketErrorQuark(), code, msg); + error.Set(socket_domain, code, msg); } static inline void -SetSocketError(GError **error_r) +SetSocketError(Error &error) { - SetSocketError(error_r, GetSocketError()); + SetSocketError(error, GetSocketError()); } -gcc_malloc -static inline GError * +gcc_const +static inline Error NewSocketError(socket_error_t code) { - const SocketErrorMessage msg(code); - return g_error_new_literal(SocketErrorQuark(), code, msg); + Error error; + SetSocketError(error, code); + return error; } -gcc_malloc -static inline GError * +gcc_pure +static inline Error NewSocketError() { return NewSocketError(GetSocketError()); -- cgit v1.2.3