Ejemplo n.º 1
0
void
mono_error_set_bad_image (MonoError *oerror, MonoImage *image, const char *msg_format, ...)
{
	MonoErrorInternal *error = (MonoErrorInternal*)oerror;
	mono_error_prepare (error);

	error->error_code = MONO_ERROR_BAD_IMAGE;
	error->assembly_name = image ? mono_image_get_name (image) : "<no_image>";
	set_error_message ();
}
Ejemplo n.º 2
0
void
mono_error_set_type_load_class (MonoError *oerror, MonoClass *klass, const char *msg_format, ...)
{
	MonoErrorInternal *error = (MonoErrorInternal*)oerror;
	mono_error_prepare (error);

	error->error_code = MONO_ERROR_TYPE_LOAD;
	mono_error_set_class (oerror, klass);
	set_error_message ();
}
Ejemplo n.º 3
0
void
mono_error_set_member_access (MonoError *oerror, const char *msg_format, ...)
{
	MonoErrorInternal *error = (MonoErrorInternal*)oerror;

	mono_error_prepare (error);
	error->error_code = MONO_ERROR_MEMBER_ACCESS;

	set_error_message ();
}
Ejemplo n.º 4
0
void
mono_error_set_generic_errorv (MonoError *oerror, const char *name_space, const char *name, const char *msg_format, va_list args)
{
	MonoErrorInternal *error = (MonoErrorInternal*)oerror;
	mono_error_prepare (error);

	error->error_code = MONO_ERROR_GENERIC;
	mono_error_set_corlib_exception (oerror, name_space, name);
	set_error_messagev ();
}
Ejemplo n.º 5
0
/*
 * Sets @error to be of type @error_code with message @message
 * XXX only works for MONO_ERROR_MISSING_METHOD, MONO_ERROR_BAD_IMAGE, MONO_ERROR_FILE_NOT_FOUND and MONO_ERROR_MISSING_FIELD for now
*/
void
mono_error_set_specific (MonoError *oerror, int error_code, const char *message)
{
	MonoErrorInternal *error = (MonoErrorInternal*)oerror;
	mono_error_prepare (error);

	error->error_code = error_code;
	error->full_message = message;
	error->flags |= MONO_ERROR_FREE_STRINGS;
}
Ejemplo n.º 6
0
void
mono_error_set_invalid_program (MonoError *oerror, const char *msg_format, ...)
{
	MonoErrorInternal *error = (MonoErrorInternal*)oerror;

	mono_error_prepare (error);
	error->error_code = MONO_ERROR_INVALID_PROGRAM;

	set_error_message ();
}
Ejemplo n.º 7
0
void
mono_error_set_out_of_memory (MonoError *oerror, const char *msg_format, ...)
{
	MonoErrorInternal *error = (MonoErrorInternal*)oerror;
	mono_error_prepare (error);

	error->error_code = MONO_ERROR_OUT_OF_MEMORY;

	set_error_message ();
}
Ejemplo n.º 8
0
void
mono_error_set_bad_image_name (MonoError *oerror, const char *assembly_name, const char *msg_format, ...)
{
	MonoErrorInternal *error = (MonoErrorInternal*)oerror;
	mono_error_prepare (error);

	error->error_code = MONO_ERROR_BAD_IMAGE;
	mono_error_set_assembly_name (oerror, assembly_name);
	set_error_message ();
}
Ejemplo n.º 9
0
void
mono_error_set_field_load (MonoError *oerror, MonoClass *klass, const char *field_name, const char *msg_format, ...)
{
	MonoErrorInternal *error = (MonoErrorInternal*)oerror;
	mono_error_prepare (error);

	error->error_code = MONO_ERROR_MISSING_FIELD;
	mono_error_set_class (oerror, klass);
	mono_error_set_member_name (oerror, field_name);
	set_error_message ();	
}
Ejemplo n.º 10
0
void
mono_error_set_argument (MonoError *oerror, const char *argument, const char *msg)
{
	MonoErrorInternal *error = (MonoErrorInternal*)oerror;
	mono_error_prepare (error);

	error->error_code = MONO_ERROR_ARGUMENT;
	error->first_argument = argument;
	if (msg && msg [0] && !(error->full_message = g_strdup (msg)))
		error->flags |= MONO_ERROR_INCOMPLETE;
}
Ejemplo n.º 11
0
void
mono_error_set_argument (MonoError *oerror, const char *argument, const char *msg_format, ...)
{
	MonoErrorInternal *error = (MonoErrorInternal*)oerror;
	mono_error_prepare (error);

	error->error_code = MONO_ERROR_ARGUMENT;
	error->type_name = argument; /*use the first available string slot*/

	set_error_message ();
}
Ejemplo n.º 12
0
void
mono_error_set_assembly_load (MonoError *oerror, const char *assembly_name, const char *msg_format, ...)
{
	MonoErrorInternal *error = (MonoErrorInternal*)oerror;
	mono_error_prepare (error);

	error->error_code = MONO_ERROR_FILE_NOT_FOUND;
	mono_error_set_assembly_name (oerror, assembly_name);

	set_error_message ();
}
Ejemplo n.º 13
0
void
mono_error_set_argument_null (MonoError *oerror, const char *argument, const char *msg_format, ...)
{
	MonoErrorInternal *error = (MonoErrorInternal*)oerror;
	mono_error_prepare (error);

	error->error_code = MONO_ERROR_ARGUMENT_NULL;
	error->first_argument = argument;

	set_error_message ();
}
Ejemplo n.º 14
0
void
mono_error_set_type_load_name (MonoError *oerror, const char *type_name, const char *assembly_name, const char *msg_format, ...)
{
	MonoErrorInternal *error = (MonoErrorInternal*)oerror;
	mono_error_prepare (error);

	error->error_code = MONO_ERROR_TYPE_LOAD;
	mono_error_set_type_name (oerror, type_name);
	mono_error_set_assembly_name (oerror, assembly_name);
	set_error_message ();
}
Ejemplo n.º 15
0
void
mono_error_set_out_of_memory (MonoError *oerror, const char *msg_format, ...)
{
	MonoErrorInternal *error = (MonoErrorInternal*)oerror;
	va_list args;
	mono_error_prepare (error);

	error->error_code = MONO_ERROR_OUT_OF_MEMORY;
	va_start (args, msg_format);
	g_vsnprintf (error->message, sizeof (error->message), msg_format, args);
	va_end (args);
}
Ejemplo n.º 16
0
void
mono_error_set_not_verifiable (MonoError *oerror, MonoMethod *method, const char *msg_format, ...)
{
	MonoErrorInternal *error = (MonoErrorInternal*)oerror;
	mono_error_prepare (error);

	error->error_code = MONO_ERROR_NOT_VERIFIABLE;
	mono_error_set_class (oerror, method->klass);
	if (method)
		mono_error_set_member_name (oerror, mono_method_full_name (method, 1));

	set_error_message ();
}
Ejemplo n.º 17
0
void
mono_error_set_from_loader_error (MonoError *oerror)
{
	MonoLoaderError *loader_error = mono_loader_get_last_error ();
	MonoErrorInternal *error = (MonoErrorInternal*)oerror;
	gboolean dup_strings = TRUE;

	mono_error_prepare (error);

	if (!loader_error) {
		mono_error_set_generic_error (oerror, "System", "ExecutionEngineException", "Runtime tried to produce a mono-error from an empty loader-error");
		return;
	}

	switch (loader_error->exception_type) {
	case MONO_EXCEPTION_NONE:
		mono_error_set_generic_error (oerror, "System", "ExecutionEngineException", "Runtime tried to produce a mono-error from a non-error loader-error");
		break;

	case MONO_EXCEPTION_INVALID_PROGRAM:
		mono_error_set_generic_error (oerror, "System", "InvalidProgramException", "Failed for unknown reasons.");
		break;

	case MONO_EXCEPTION_UNVERIFIABLE_IL:
		mono_error_set_generic_error (oerror, "System.Security", "VerificationException", "Failed for unknown reasons.");
		break;

	case MONO_EXCEPTION_MISSING_METHOD:
		error->error_code = MONO_ERROR_MISSING_METHOD;
		mono_error_set_type_name (oerror, loader_error->class_name);
		mono_error_set_member_name (oerror, loader_error->member_name);
		error->full_message = g_strdup ("Failed for unknown reasons.");
		break;

	case MONO_EXCEPTION_MISSING_FIELD:
		mono_error_set_field_load (oerror, loader_error->klass, loader_error->member_name, "Failed for unknown reasons.");
		break;

	case MONO_EXCEPTION_TYPE_LOAD:
		mono_error_set_type_load_name (oerror, g_strdup (loader_error->class_name), g_strdup (loader_error->assembly_name), "Failed for unknown reasons.");
		dup_strings = FALSE;
		break;
	
	case MONO_EXCEPTION_FILE_NOT_FOUND:
		mono_error_set_assembly_load_simple (oerror, loader_error->assembly_name, loader_error->ref_only);
		break;

	case MONO_EXCEPTION_METHOD_ACCESS:
		mono_error_set_generic_error (oerror, "System", "MethodAccessException", "Failed for unknown reasons.");
		break;

	case MONO_EXCEPTION_FIELD_ACCESS:
		mono_error_set_generic_error (oerror, "System", "FieldAccessException", "Failed for unknown reasons.");
		break;

	case MONO_EXCEPTION_OBJECT_SUPPLIED:
	case MONO_EXCEPTION_GENERIC_SHARING_FAILED:
		mono_error_set_generic_error (oerror, "System", "ExecutionEngineException", "Runtime tried to produce a mono-error from JIT internal error %d", loader_error->exception_type);
		break;

	case MONO_EXCEPTION_BAD_IMAGE:
		mono_error_set_bad_image_name (oerror, "<unknown>", "%s", loader_error->msg);
		break;

	case MONO_EXCEPTION_OUT_OF_MEMORY:
		mono_error_set_out_of_memory (oerror, "Failed for unknown reasons.");
		break;

	default:
		mono_error_set_generic_error (oerror, "System", "ExecutionEngineException", "Runtime tried to produce an unknown loader-error %d", loader_error->exception_type);
		break;
	}

	mono_error_dup_strings (oerror, dup_strings);
	mono_loader_clear_error ();
}
Ejemplo n.º 18
0
void
mono_error_set_from_loader_error (MonoError *oerror)
{
	MonoLoaderError *loader_error = mono_loader_get_last_error ();
	MonoErrorInternal *error = (MonoErrorInternal*)oerror;

	mono_error_prepare (error);


	if (!loader_error) {
		mono_error_set_generic_error (oerror, "System", "ExecutionEngineException", "Runtime tried to produce a mono-error from an empty loader-error");
		return;
	}

	switch (loader_error->exception_type) {
	case MONO_EXCEPTION_NONE:
		mono_error_set_generic_error (oerror, "System", "ExecutionEngineException", "Runtime tried to produce a mono-error from a non-error loader-error");
		break;
	case MONO_EXCEPTION_SECURITY_LINKDEMAND:
	case MONO_EXCEPTION_SECURITY_INHERITANCEDEMAND:
		mono_error_set_generic_error (oerror, "System.Security", "SecurityException", "Failed for unknown reasons.");
		break;

	case MONO_EXCEPTION_INVALID_PROGRAM:
		mono_error_set_generic_error (oerror, "System", "InvalidProgramException", "Failed for unknown reasons.");
		break;

	case MONO_EXCEPTION_UNVERIFIABLE_IL:
		mono_error_set_generic_error (oerror, "System.Security", "VerificationException", "Failed for unknown reasons.");
		break;

	case MONO_EXCEPTION_MISSING_METHOD:
		error->error_code = MONO_ERROR_MISSING_METHOD;
		mono_error_set_type_name (oerror, loader_error->class_name);
		mono_error_set_member_name (oerror, loader_error->member_name);
		g_snprintf (error->message, sizeof (error->message), "Failed for unknown reasons.");
		break;

	case MONO_EXCEPTION_MISSING_FIELD:
		mono_error_set_field_load (oerror, loader_error->klass, loader_error->member_name, "Failed for unknown reasons.");
		break;

	case MONO_EXCEPTION_TYPE_LOAD:
		mono_error_set_type_load_name (oerror, loader_error->class_name, loader_error->assembly_name, "Failed for unknown reasons.");
		break;
	
	case MONO_EXCEPTION_FILE_NOT_FOUND:
		if (loader_error->ref_only)
			mono_error_set_assembly_load (oerror, loader_error->assembly_name, "Cannot resolve dependency to assembly because it has not been preloaded. When using the ReflectionOnly APIs, dependent assemblies must be pre-loaded or loaded on demand through the ReflectionOnlyAssemblyResolve event.");
		else
			mono_error_set_assembly_load (oerror, loader_error->assembly_name, "Could not load file or assembly or one of its dependencies.");
		break;

	case MONO_EXCEPTION_METHOD_ACCESS:
		mono_error_set_generic_error (oerror, "System", "MethodAccessException", "Failed for unknown reasons.");
		break;

	case MONO_EXCEPTION_FIELD_ACCESS:
		mono_error_set_generic_error (oerror, "System", "FieldAccessException", "Failed for unknown reasons.");
		break;

	case MONO_EXCEPTION_OBJECT_SUPPLIED:
	case MONO_EXCEPTION_GENERIC_SHARING_FAILED:
		mono_error_set_generic_error (oerror, "System", "ExecutionEngineException", "Runtime tried to produce a mono-error from JIT internal error %d", loader_error->exception_type);
		break;

	case MONO_EXCEPTION_BAD_IMAGE:
		mono_error_set_bad_image_name (oerror, "<unknown>", "%s", loader_error->msg);
		break;

	case MONO_EXCEPTION_OUT_OF_MEMORY:
		mono_error_set_out_of_memory (oerror, "Failed for unknown reasons.");
		break;

	default:
		mono_error_set_generic_error (oerror, "System", "ExecutionEngineException", "Runtime tried to produce an unknown loader-error %d", loader_error->exception_type);
		break;
	}

	mono_error_dup_strings (oerror, TRUE);
	mono_loader_clear_error ();
}