libpurple/protocols/facebook/api.c

branch
facebook
changeset 37312
d6cb70301fea
parent 37309
556eea7a45da
child 37313
600f41974cb3
equal deleted inserted replaced
37311:f9437ac8aa5d 37312:d6cb70301fea
21 21
22 #include <json-glib/json-glib.h> 22 #include <json-glib/json-glib.h>
23 #include <stdarg.h> 23 #include <stdarg.h>
24 #include <string.h> 24 #include <string.h>
25 25
26 #include "glibcompat.h"
27
26 #include "api.h" 28 #include "api.h"
27 #include "glibcompat.h"
28 #include "http.h" 29 #include "http.h"
29 #include "json.h" 30 #include "json.h"
30 #include "marshal.h" 31 #include "marshal.h"
31 #include "thrift.h" 32 #include "thrift.h"
32 #include "util.h" 33 #include "util.h"
327 328
328 g_return_val_if_fail(FB_IS_API(api), FALSE); 329 g_return_val_if_fail(FB_IS_API(api), FALSE);
329 priv = api->priv; 330 priv = api->priv;
330 331
331 if (G_UNLIKELY(size == 0)) { 332 if (G_UNLIKELY(size == 0)) {
332 g_set_error(&err, FB_API_ERROR, FB_API_ERROR_GENERAL, 333 fb_api_error(api, FB_API_ERROR_GENERAL, _("Empty JSON data"));
333 _("Invalid JSON data")); 334 return FALSE;
334 FB_API_ERROR_CHK(api, err, return FALSE);
335 } 335 }
336 336
337 root = fb_json_node_new(data, size, &err); 337 root = fb_json_node_new(data, size, &err);
338 FB_API_ERROR_CHK(api, err, return FALSE); 338 FB_API_ERROR_CHK(api, err, return FALSE);
339 339
1041 } 1041 }
1042 1042
1043 void 1043 void
1044 fb_api_error(FbApi *api, FbApiError error, const gchar *format, ...) 1044 fb_api_error(FbApi *api, FbApiError error, const gchar *format, ...)
1045 { 1045 {
1046 gchar *str; 1046 GError *err;
1047 GError *err = NULL;
1048 va_list ap; 1047 va_list ap;
1049 1048
1050 g_return_if_fail(FB_IS_API(api)); 1049 g_return_if_fail(FB_IS_API(api));
1051 1050
1052 va_start(ap, format); 1051 va_start(ap, format);
1053 str = g_strdup_vprintf(format, ap); 1052 err = g_error_new_valist(FB_API_ERROR, error, format, ap);
1054 va_end(ap); 1053 va_end(ap);
1055
1056 g_set_error(&err, FB_API_ERROR, error, "%s", str);
1057 g_free(str);
1058 1054
1059 g_signal_emit_by_name(api, "error", err); 1055 g_signal_emit_by_name(api, "error", err);
1060 g_error_free(err); 1056 g_error_free(err);
1061 } 1057 }
1062 1058

mercurial