]> granicus.if.org Git - icinga2/commitdiff
Improve error message for invalid field access
authorGunnar Beutner <gunnar@beutner.name>
Thu, 19 Mar 2015 12:47:40 +0000 (13:47 +0100)
committerGunnar Beutner <gunnar@beutner.name>
Thu, 19 Mar 2015 12:48:51 +0000 (13:48 +0100)
fixes #8769

lib/config/vmops.hpp

index 5bb3cf4510c64dd67eff4f68888062f5ba793735..42f338d26a26f389e771ca2e6be55b2d5cf615a6 100644 (file)
@@ -186,7 +186,8 @@ public:
 
        static inline Value GetPrototypeField(const Value& context, const String& field, bool not_found_error = true, const DebugInfo& debugInfo = DebugInfo())
        {
-               Type::Ptr type = context.GetReflectionType();
+               Type::Ptr ctype = context.GetReflectionType();
+               Type::Ptr type = ctype;
 
                do {
                        Object::Ptr object = type->GetPrototype();
@@ -198,7 +199,7 @@ public:
                } while (type);
 
                if (not_found_error)
-                       BOOST_THROW_EXCEPTION(ScriptError("Invalid field name: '" + field + "'", debugInfo));
+                       BOOST_THROW_EXCEPTION(ScriptError("Invalid field access (for value of type '" + ctype->GetName() + "'): '" + field + "'", debugInfo));
                else
                        return Empty;
        }