2005-01-17 Zoltan Varga <vargaz@freemail.hu>
[mono.git] / mono / metadata / exception.c
index 177c3d9d899936480a41451dbbb9de905d999755..eb422a09796be2d26bbdd5d6a47c37f32f29af43 100644 (file)
@@ -49,6 +49,32 @@ mono_exception_from_name_domain (MonoDomain *domain, MonoImage *image,
        return (MonoException *)o;
 }
 
+
+/**
+ * mono_exception_from_token:
+ * @image: the Mono image where to look for the class
+ * @token: The type token of the class
+ *
+ * Creates an exception of the type given by @token.
+ *
+ * Returns: the initialized exception instance.
+ */
+MonoException *
+mono_exception_from_token (MonoImage *image, guint32 token)
+{
+       MonoClass *klass;
+       MonoObject *o;
+
+       klass = mono_class_get (image, token);
+
+       o = mono_object_new (mono_domain_get (), klass);
+       g_assert (o != NULL);
+       
+       mono_runtime_object_init (o);
+
+       return (MonoException *)o;
+}
+
 /**
  * mono_exception_from_name_two_strings:
  * @image: the Mono image where to look for the class
@@ -306,6 +332,15 @@ mono_get_exception_file_not_found (MonoString *fname)
                mono_get_corlib (), "System.IO", "FileNotFoundException", fname, fname);
 }
 
+MonoException *
+mono_get_exception_file_not_found2 (const guchar *msg, MonoString *fname)
+{
+       MonoString *s = mono_string_new (mono_domain_get (), msg);
+
+       return mono_exception_from_name_two_strings (
+               mono_get_corlib (), "System.IO", "FileNotFoundException", s, fname);
+}
+
 MonoException *
 mono_get_exception_type_initialization (const gchar *type_name, MonoException *inner)
 {