From 3bf914307926bbf0f91ce12eadf778d2690dafe0 Mon Sep 17 00:00:00 2001 From: Mikhail Pozdnyakov Date: Thu, 27 Feb 2020 16:47:58 +0200 Subject: [PATCH] Emit error message with URL details on load error 404 --- .../default/src/mbgl/storage/online_file_source.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/platform/default/src/mbgl/storage/online_file_source.cpp b/platform/default/src/mbgl/storage/online_file_source.cpp index 8aa2d225e..f578eb147 100644 --- a/platform/default/src/mbgl/storage/online_file_source.cpp +++ b/platform/default/src/mbgl/storage/online_file_source.cpp @@ -459,6 +459,15 @@ void OnlineFileRequest::schedule(optional expires) { }); } +namespace { + +inline std::string sanitizeURL(std::string& url) { + std::size_t queryIndex = url.find('?'); + return (queryIndex != std::string::npos) ? std::string(url, 0, queryIndex) : url; +} + +} // namespace + void OnlineFileRequest::completed(Response response) { // If we didn't get various caching headers in the response, continue using the // previous values. Otherwise, update the previous values to the new values. @@ -498,6 +507,9 @@ void OnlineFileRequest::completed(Response response) { } if (response.error) { + if (response.error->reason == Response::Error::Reason::NotFound) { + Log::Error(Event::General, "The resource `%s` not found", sanitizeURL(resource.url).c_str()); + } failedRequests++; failedRequestReason = response.error->reason; retryAfter = response.error->retryAfter;