[core] Rationalize error handling for resource loading
* Standardize on std::exception_ptr as the error representation (fixes #2854). * Don't format textual strings at the error source; pass on the constituent data via observer method parameters instead. * Use the null object pattern to simplify observer notification code. * Further refactoring for ResourceLoading tests.
This commit is contained in:
@@ -5,7 +5,6 @@
|
||||
#include <mbgl/storage/file_source.hpp>
|
||||
#include <mbgl/util/thread_context.hpp>
|
||||
|
||||
#include <sstream>
|
||||
#include <utility>
|
||||
|
||||
namespace mbgl {
|
||||
@@ -194,9 +193,7 @@ std::unique_ptr<FileRequest> VectorTileMonitor::monitorTile(const GeometryTileMo
|
||||
callback(nullptr, nullptr, res.modified, res.expires);
|
||||
return;
|
||||
} else {
|
||||
std::stringstream message;
|
||||
message << "Failed to load [" << url << "]: " << res.error->message;
|
||||
callback(std::make_exception_ptr(std::runtime_error(message.str())), nullptr, res.modified, res.expires);
|
||||
callback(std::make_exception_ptr(std::runtime_error(res.error->message)), nullptr, res.modified, res.expires);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user