return r;
}
-
-static int pakfire_xfer_handle_api_error(
- struct pakfire_xfer* xfer, const struct json_object* error) {
- struct json_object* message = NULL;
- struct json_object* code = NULL;
- const char* m = NULL;
- unsigned int c = 0;
-
- // Fetch the URL
- const char* url = pakfire_xfer_get_effective_url(xfer);
-
- // Fetch the code
- if (!json_object_object_get_ex(error, "code", &code))
- return -EBADMSG;
-
- // Check if the code is an integer
- if (!json_object_is_type(code, json_type_int))
- return -EBADMSG;
-
- // Fetch the message
- if (!json_object_object_get_ex(error, "message", &message))
- return -EBADMSG;
-
- // Check if the message is a string
- if (!json_object_is_type(message, json_type_string))
- return -EBADMSG;
-
- c = json_object_get_uint64(code);
- m = json_object_get_string(message);
-
- // Log the error
- ERROR(xfer->ctx, "%s responded with error %u (%s):\n %s\n",
- url, c, strerror(c), m);
-
- return -c;
-}