From 4ad75c9546e8341112f3c773d85b4b83f8481d53 Mon Sep 17 00:00:00 2001 From: Thomas Goyne Date: Tue, 5 Sep 2017 16:30:26 -0700 Subject: [PATCH] Don't discard the actual error message in validated_get_X --- src/js_schema.hpp | 3 ++- src/js_types.hpp | 5 +++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/js_schema.hpp b/src/js_schema.hpp index c6b8b514..e32e2427 100644 --- a/src/js_schema.hpp +++ b/src/js_schema.hpp @@ -232,7 +232,8 @@ ObjectSchema Schema::parse_object_schema(ContextType ctx, ObjectType object_s } template -realm::Schema Schema::parse_schema(ContextType ctx, ObjectType schema_object, ObjectDefaultsMap &defaults, ConstructorMap &constructors) { +realm::Schema Schema::parse_schema(ContextType ctx, ObjectType schema_object, + ObjectDefaultsMap &defaults, ConstructorMap &constructors) { std::vector schema; uint32_t length = Object::validated_get_length(ctx, schema_object); diff --git a/src/js_types.hpp b/src/js_types.hpp index af30de83..1e32c2b6 100644 --- a/src/js_types.hpp +++ b/src/js_types.hpp @@ -20,6 +20,7 @@ #include "execution_context_id.hpp" #include "property.hpp" +#include "util/format.hpp" #include #include @@ -223,7 +224,7 @@ struct Object { return Value::validated_to_##type(ctx, get_property(ctx, object, key), std::string(key).c_str()); \ } \ catch (std::invalid_argument &e) { \ - throw message ? std::invalid_argument(message) : e; \ + throw message ? std::invalid_argument(util::format("Failed to read %1: %2", message, e.what())) : e; \ } \ } \ static return_t validated_get_##type(ContextType ctx, const ObjectType &object, uint32_t index, const char *message = nullptr) { \ @@ -231,7 +232,7 @@ struct Object { return Value::validated_to_##type(ctx, get_property(ctx, object, index)); \ } \ catch (std::invalid_argument &e) { \ - throw message ? std::invalid_argument(message) : e; \ + throw message ? std::invalid_argument(util::format("Failed to read %1: %2", message, e.what())) : e; \ } \ }