MonoArray *args = prepare_run_main (method, argc, argv);
int res;
if (exc) {
- res = mono_runtime_try_exec_main (method, args, exc, &error);
- if (*exc == NULL && !is_ok (&error))
- *exc = (MonoObject*) mono_error_convert_to_exception (&error);
- else
- mono_error_cleanup (&error);
+ res = mono_runtime_try_exec_main (method, args, exc);
} else {
res = mono_runtime_exec_main_checked (method, args, &error);
mono_error_raise_exception (&error); /* OK to throw, external only without a better alternative */
*/
int
mono_runtime_try_run_main (MonoMethod *method, int argc, char* argv[],
- MonoObject **exc, MonoError *error)
+ MonoObject **exc)
{
g_assert (exc);
- mono_error_init (error);
MonoArray *args = prepare_run_main (method, argc, argv);
- return mono_runtime_try_exec_main (method, args, exc, error);
+ return mono_runtime_try_exec_main (method, args, exc);
}
}
static int
-do_try_exec_main (MonoMethod *method, MonoArray *args, MonoObject **exc, MonoError *error)
+do_try_exec_main (MonoMethod *method, MonoArray *args, MonoObject **exc)
{
MONO_REQ_GC_UNSAFE_MODE;
gpointer pa [1];
int rval;
- mono_error_init (error);
g_assert (args);
g_assert (exc);
/* FIXME: check signature of method */
if (mono_method_signature (method)->ret->type == MONO_TYPE_I4) {
+ MonoError inner_error;
MonoObject *res;
- res = mono_runtime_try_invoke (method, NULL, pa, exc, error);
- if (*exc == NULL && !mono_error_ok (error))
- *exc = (MonoObject*) mono_error_convert_to_exception (error);
+ res = mono_runtime_try_invoke (method, NULL, pa, exc, &inner_error);
+ if (*exc == NULL && !mono_error_ok (&inner_error))
+ *exc = (MonoObject*) mono_error_convert_to_exception (&inner_error);
else
- mono_error_cleanup (error);
+ mono_error_cleanup (&inner_error);
if (*exc == NULL)
rval = *(guint32 *)((char *)res + sizeof (MonoObject));
mono_environment_exitcode_set (rval);
} else {
- mono_runtime_try_invoke (method, NULL, pa, exc, error);
- if (*exc == NULL && !mono_error_ok (error))
- *exc = (MonoObject*) mono_error_convert_to_exception (error);
+ MonoError inner_error;
+ mono_runtime_try_invoke (method, NULL, pa, exc, &inner_error);
+ if (*exc == NULL && !mono_error_ok (&inner_error))
+ *exc = (MonoObject*) mono_error_convert_to_exception (&inner_error);
else
- mono_error_cleanup (error);
+ mono_error_cleanup (&inner_error);
if (*exc == NULL)
rval = 0;
MonoError error;
prepare_thread_to_exec_main (mono_object_domain (args), method);
if (exc) {
- int rval = do_try_exec_main (method, args, exc, &error);
- if (*exc == NULL && !is_ok (&error))
- *exc = (MonoObject*) mono_error_convert_to_exception (&error);
- else
- mono_error_cleanup (&error);
+ int rval = do_try_exec_main (method, args, exc);
return rval;
} else {
int rval = do_exec_main_checked (method, args, &error);
* On failure sets @error if Main couldn't be executed, or @exc if it threw an exception.
*/
int
-mono_runtime_try_exec_main (MonoMethod *method, MonoArray *args, MonoObject **exc, MonoError *error)
+mono_runtime_try_exec_main (MonoMethod *method, MonoArray *args, MonoObject **exc)
{
- mono_error_init (error);
prepare_thread_to_exec_main (mono_object_domain (args), method);
- return do_try_exec_main (method, args, exc, error);
+ return do_try_exec_main (method, args, exc);
}