Don't discard the actual error message in validated_get_X

This commit is contained in:
Thomas Goyne 2017-09-05 16:30:26 -07:00
parent b8fd4fb861
commit 4ad75c9546
2 changed files with 5 additions and 3 deletions

View File

@ -232,7 +232,8 @@ ObjectSchema Schema<T>::parse_object_schema(ContextType ctx, ObjectType object_s
}
template<typename T>
realm::Schema Schema<T>::parse_schema(ContextType ctx, ObjectType schema_object, ObjectDefaultsMap &defaults, ConstructorMap &constructors) {
realm::Schema Schema<T>::parse_schema(ContextType ctx, ObjectType schema_object,
ObjectDefaultsMap &defaults, ConstructorMap &constructors) {
std::vector<ObjectSchema> schema;
uint32_t length = Object::validated_get_length(ctx, schema_object);

View File

@ -20,6 +20,7 @@
#include "execution_context_id.hpp"
#include "property.hpp"
#include "util/format.hpp"
#include <stdexcept>
#include <string>
@ -223,7 +224,7 @@ struct Object {
return Value<T>::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<T>::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; \
} \
}