Merge pull request #2820 from kumpera/license-change-rebased
[mono.git] / mono / metadata / reflection.c
index 59e958c10f67db3cbe116a210cad48b715e5e227..200c41e5f804fa015801317184020629b1c46501 100644 (file)
@@ -8,6 +8,7 @@
  * Copyright 2004-2009 Novell, Inc (http://www.novell.com)
  * Copyright 2011 Rodrigo Kumpera
  *
+ * Licensed under the MIT license. See LICENSE file in the project root for full license information.
  */
 #include <config.h>
 #include "mono/utils/mono-digest.h"
@@ -11133,11 +11134,11 @@ handle_type:
                
                klass = mono_object_class (arg);
 
-               if (mono_object_isinst_checked (arg, mono_defaults.systemtype_class, &error)) {
+               if (mono_object_isinst_checked (arg, mono_defaults.systemtype_class, error)) {
                        *p++ = 0x50;
                        goto handle_type;
                } else {
-                       mono_error_raise_exception (&error); /* FIXME don't raise here */
+                       return_if_nok (error);
                }
 
                if (klass->enumtype) {
@@ -13695,25 +13696,27 @@ mono_reflection_lookup_signature (MonoImage *image, MonoMethod *method, guint32
  * LOCKING: Take the loader lock
  */
 gpointer
-mono_reflection_lookup_dynamic_token (MonoImage *image, guint32 token, gboolean valid_token, MonoClass **handle_class, MonoGenericContext *context)
+mono_reflection_lookup_dynamic_token (MonoImage *image, guint32 token, gboolean valid_token, MonoClass **handle_class, MonoGenericContext *context, MonoError *error)
 {
-       MonoError error;
        MonoDynamicImage *assembly = (MonoDynamicImage*)image;
        MonoObject *obj;
        MonoClass *klass;
 
+       mono_error_init (error);
+       
        obj = lookup_dyn_token (assembly, token);
        if (!obj) {
                if (valid_token)
                        g_error ("Could not find required dynamic token 0x%08x", token);
-               else
+               else {
+                       mono_error_set_execution_engine (error, "Could not find dynamic token 0x%08x", token);
                        return NULL;
+               }
        }
 
        if (!handle_class)
                handle_class = &klass;
-       gpointer result = resolve_object (image, obj, handle_class, context, &error);
-       mono_error_raise_exception (&error); /* FIXME don't raise here */
+       gpointer result = resolve_object (image, obj, handle_class, context, error);
        return result;
 }