From 8e442411b0339072666f2b434963a0bd88215f3d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konstantin=20Ka=CC=88fer?= Date: Tue, 15 Apr 2014 11:45:26 -0400 Subject: [PATCH] add human-readable error messages --- linux/request.cpp | 6 ++++++ src/map/tile_data.cpp | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/linux/request.cpp b/linux/request.cpp index 558195760..617ee5e06 100644 --- a/linux/request.cpp +++ b/linux/request.cpp @@ -101,6 +101,12 @@ void Request::request(void *ptr) { code = curl_easy_perform(curl); curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &res.code); + // Add human-readable error code + if (code != CURLE_OK) { + res.error_message = curl_easy_strerror(code); + res.code = -1; + } + if (code != CURLE_ABORTED_BY_CALLBACK) { req->background_function(&res); } diff --git a/src/map/tile_data.cpp b/src/map/tile_data.cpp index e35fc0645..4df01778d 100644 --- a/src/map/tile_data.cpp +++ b/src/map/tile_data.cpp @@ -58,7 +58,7 @@ void TileData::request() { tile->data.swap(res->body); tile->parse(); } else { - fprintf(stderr, "tile loading failed (%s): %d\n", url.c_str(), res->code); + fprintf(stderr, "[%s] tile loading failed: %d, %s\n", url.c_str(), res->code, res->error_message.c_str()); } }, []() { platform::restart();