klass = mono_class_load_from_name (image, name_space, name);
o = mono_object_new_checked (domain, klass, &error);
- g_assert (o != NULL && mono_error_ok (&error)); /* FIXME don't swallow the error */
+ mono_error_assert_ok (&error);
if (domain != caller_domain)
mono_domain_set_internal (domain);
- mono_runtime_object_init (o);
+ mono_runtime_object_init_checked (o, &error);
+ mono_error_assert_ok (&error);
+
if (domain != caller_domain)
mono_domain_set_internal (caller_domain);
MonoObject *o;
klass = mono_class_get_checked (image, token, &error);
- g_assert (mono_error_ok (&error)); /* FIXME handle the error. */
+ mono_error_assert_ok (&error);
o = mono_object_new_checked (mono_domain_get (), klass, &error);
- g_assert (o != NULL && mono_error_ok (&error)); /* FIXME don't swallow the error */
+ mono_error_assert_ok (&error);
- mono_runtime_object_init (o);
+ mono_runtime_object_init_checked (o, &error);
+ mono_error_assert_ok (&error);
return (MonoException *)o;
}
mono_raise_exception (ex);
}
-void
+/**
+ * mono_error_set_pending_exception:
+ * @error: The error
+ *
+ *
+ * If @error is set, convert it to an exception and set the pending exception for the current icall.
+ * Returns TRUE if @error was set, or FALSE otherwise, so that you can write:
+ * if (mono_error_set_pending_exception (error)) {
+ * { ... cleanup code ... }
+ * return;
+ * }
+ */
+gboolean
mono_error_set_pending_exception (MonoError *error)
{
MonoException *ex = mono_error_convert_to_exception (error);
- if (ex)
+ if (ex) {
mono_set_pending_exception (ex);
+ return TRUE;
+ } else {
+ return FALSE;
+ }
}