summaryrefslogtreecommitdiff
path: root/include/mbgl/util/string.hpp
diff options
context:
space:
mode:
authorJohn Firebaugh <john.firebaugh@gmail.com>2016-03-15 12:45:07 -0700
committerJohn Firebaugh <john.firebaugh@gmail.com>2016-03-16 11:04:08 -0700
commit46830f1ea5e1054d35466731345e8b1f2b5dd380 (patch)
tree3c4181a19fc1480e04ea0cd15d51dee6dc06f604 /include/mbgl/util/string.hpp
parent4c455f4053e30881655648a7151561278e04ff62 (diff)
downloadqtlocation-mapboxgl-46830f1ea5e1054d35466731345e8b1f2b5dd380.tar.gz
[core] Assert and guard against null std::exception_ptr in toString
We don't expect toString to be called with a null std::exception_ptr. But if it is, we'd prefer not to terminate the process in release builds.
Diffstat (limited to 'include/mbgl/util/string.hpp')
-rw-r--r--include/mbgl/util/string.hpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/include/mbgl/util/string.hpp b/include/mbgl/util/string.hpp
index 6c2433534e..51ee848f22 100644
--- a/include/mbgl/util/string.hpp
+++ b/include/mbgl/util/string.hpp
@@ -28,6 +28,12 @@ inline std::string toString(uint8_t num) {
}
inline std::string toString(std::exception_ptr error) {
+ assert(error);
+
+ if (!error) {
+ return "(null)";
+ }
+
try {
std::rethrow_exception(error);
} catch (const std::exception& ex) {