From 46830f1ea5e1054d35466731345e8b1f2b5dd380 Mon Sep 17 00:00:00 2001 From: John Firebaugh Date: Tue, 15 Mar 2016 12:45:07 -0700 Subject: [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. --- include/mbgl/util/string.hpp | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'include/mbgl/util') 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) { -- cgit v1.2.1