cheader = mono_method_get_header (cmethod);
if (cheader == NULL || mono_loader_get_last_error ()) {
- MonoLoaderError *error = mono_loader_get_last_error ();
-
if (cheader)
mono_metadata_free_mh (cheader);
- if (inline_always && error)
- mono_cfg_set_exception (cfg, error->exception_type);
+ if (inline_always && mono_loader_get_last_error ()) {
+ mono_cfg_set_exception (cfg, MONO_EXCEPTION_MONO_ERROR);
+ mono_error_set_from_loader_error (&cfg->error);
+ }
mono_loader_clear_error ();
return 0;
image = method->klass->image;
header = mono_method_get_header (method);
if (!header) {
- MonoLoaderError *error;
-
- if ((error = mono_loader_get_last_error ())) {
- mono_cfg_set_exception (cfg, error->exception_type);
+ if (mono_loader_get_last_error ()) {
+ mono_cfg_set_exception (cfg, MONO_EXCEPTION_MONO_ERROR);
+ mono_error_set_from_loader_error (&cfg->error);
} else {
mono_cfg_set_exception_invalid_program (cfg, g_strdup_printf ("Missing or incorrect header for method %s", cfg->method->name));
}
}
}
- if (!cmethod || mono_loader_get_last_error ())
- LOAD_ERROR;
+ if (!cmethod || mono_loader_get_last_error ()) {
+ if (mono_loader_get_last_error ()) {
+ mono_cfg_set_exception (cfg, MONO_EXCEPTION_MONO_ERROR);
+ mono_error_set_from_loader_error (&cfg->error);
+ CHECK_CFG_ERROR;
+ } else {
+ LOAD_ERROR;
+ }
+ }
if (!dont_verify && !cfg->skip_visibility) {
MonoMethod *target_method = cil_method;
if (method->is_inflated) {
/*
* mini_method_verify:
*
- * Verify the method using the new verfier.
+ * Verify the method using the verfier.
*
* Returns true if the method is invalid.
*/
{
GSList *tmp, *res;
gboolean is_fulltrust;
- MonoLoaderError *error;
if (method->verification_success)
return FALSE;
res = mono_method_verify_with_current_settings (method, cfg->skip_visibility, is_fulltrust);
- if ((error = mono_loader_get_last_error ())) {
- if (fail_compile)
- cfg->exception_type = error->exception_type;
- else
+ if (mono_loader_get_last_error ()) {
+ if (fail_compile) {
+ mono_cfg_set_exception (cfg, MONO_EXCEPTION_MONO_ERROR);
+ mono_error_set_from_loader_error (&cfg->error);
+ } else {
mono_loader_clear_error ();
+ }
if (res)
mono_free_verify_list (res);
return TRUE;
if (info->info.status == MONO_VERIFY_NOT_VERIFIABLE && (!is_fulltrust || info->exception_type == MONO_EXCEPTION_METHOD_ACCESS || info->exception_type == MONO_EXCEPTION_FIELD_ACCESS)) {
if (fail_compile) {
char *method_name = mono_method_full_name (method, TRUE);
-
- if (info->exception_type == MONO_EXCEPTION_METHOD_ACCESS || info->exception_type == MONO_EXCEPTION_FIELD_ACCESS) {
- if (info->exception_type == MONO_EXCEPTION_METHOD_ACCESS)
- mono_error_set_generic_error (&cfg->error, "System", "MethodAccessException", "Error verifying %s: %s", method_name, info->info.message);
- else
- mono_error_set_generic_error (&cfg->error, "System", "FieldAccessException", "Error verifying %s: %s", method_name, info->info.message);
- cfg->exception_type = MONO_EXCEPTION_MONO_ERROR;
+ char *msg = g_strdup_printf ("Error verifying %s: %s", method_name, info->info.message);
+
+ if (info->exception_type == MONO_EXCEPTION_METHOD_ACCESS)
+ mono_error_set_generic_error (&cfg->error, "System", "MethodAccessException", "%s", msg);
+ else if (info->exception_type == info->exception_type == MONO_EXCEPTION_FIELD_ACCESS)
+ mono_error_set_generic_error (&cfg->error, "System", "FieldAccessException", "%s", msg);
+ else if (info->exception_type == MONO_EXCEPTION_UNVERIFIABLE_IL)
+ mono_error_set_generic_error (&cfg->error, "System.Security", "VerificationException", msg);
+ if (!mono_error_ok (&cfg->error)) {
+ mono_cfg_set_exception (cfg, MONO_EXCEPTION_MONO_ERROR);
+ g_free (msg);
} else {
cfg->exception_type = info->exception_type;
- cfg->exception_message = g_strdup_printf ("Error verifying %s: %s", method_name, info->info.message);
+ cfg->exception_message = msg;
}
g_free (method_name);
}
header = cfg->header;
if (!header) {
- MonoLoaderError *error;
-
- if ((error = mono_loader_get_last_error ())) {
- cfg->exception_type = error->exception_type;
+ if (mono_loader_get_last_error ()) {
+ mono_cfg_set_exception (cfg, MONO_EXCEPTION_MONO_ERROR);
+ mono_error_set_from_loader_error (&cfg->error);
} else {
mono_cfg_set_exception_invalid_program (cfg, g_strdup_printf ("Missing or incorrect header for method %s", cfg->method->name));
}
case MONO_EXCEPTION_FILE_NOT_FOUND:
case MONO_EXCEPTION_BAD_IMAGE: {
/* Throw a type load exception if needed */
- MonoLoaderError *error = mono_loader_get_last_error ();
-
- if (error) {
- ex = mono_loader_error_prepare_exception (error);
+ if (cfg->exception_ptr) {
+ ex = mono_class_get_exception_for_failure ((MonoClass *)cfg->exception_ptr);
} else {
- if (cfg->exception_ptr) {
- ex = mono_class_get_exception_for_failure ((MonoClass *)cfg->exception_ptr);
- } else {
- if (cfg->exception_type == MONO_EXCEPTION_MISSING_FIELD)
- ex = mono_exception_from_name_msg (mono_defaults.corlib, "System", "MissingFieldException", cfg->exception_message);
- else if (cfg->exception_type == MONO_EXCEPTION_MISSING_METHOD)
- ex = mono_exception_from_name_msg (mono_defaults.corlib, "System", "MissingMethodException", cfg->exception_message);
- else if (cfg->exception_type == MONO_EXCEPTION_TYPE_LOAD)
- ex = mono_exception_from_name_msg (mono_defaults.corlib, "System", "TypeLoadException", cfg->exception_message);
- else if (cfg->exception_type == MONO_EXCEPTION_FILE_NOT_FOUND)
- ex = mono_exception_from_name_msg (mono_defaults.corlib, "System.IO", "FileNotFoundException", cfg->exception_message);
- else if (cfg->exception_type == MONO_EXCEPTION_BAD_IMAGE)
- ex = mono_get_exception_bad_image_format (cfg->exception_message);
- else
- g_assert_not_reached ();
- }
+ if (cfg->exception_type == MONO_EXCEPTION_MISSING_FIELD)
+ ex = mono_exception_from_name_msg (mono_defaults.corlib, "System", "MissingFieldException", cfg->exception_message);
+ else if (cfg->exception_type == MONO_EXCEPTION_MISSING_METHOD)
+ ex = mono_exception_from_name_msg (mono_defaults.corlib, "System", "MissingMethodException", cfg->exception_message);
+ else if (cfg->exception_type == MONO_EXCEPTION_TYPE_LOAD)
+ ex = mono_exception_from_name_msg (mono_defaults.corlib, "System", "TypeLoadException", cfg->exception_message);
+ else if (cfg->exception_type == MONO_EXCEPTION_FILE_NOT_FOUND)
+ ex = mono_exception_from_name_msg (mono_defaults.corlib, "System.IO", "FileNotFoundException", cfg->exception_message);
+ else if (cfg->exception_type == MONO_EXCEPTION_BAD_IMAGE)
+ ex = mono_get_exception_bad_image_format (cfg->exception_message);
+ else
+ g_assert_not_reached ();
}
break;
}
- case MONO_EXCEPTION_UNVERIFIABLE_IL:
- ex = mono_exception_from_name_msg (mono_defaults.corlib, "System.Security", "VerificationException", cfg->exception_message);
- break;
case MONO_EXCEPTION_MONO_ERROR:
g_assert (!mono_error_ok (&cfg->error));
ex = mono_error_convert_to_exception (&cfg->error);