* Authors:
* Rodrigo Kumpera (rkumpera@novell.com)
* Copyright 2009 Novell, Inc (http://www.novell.com)
+ * Licensed under the MIT license. See LICENSE file in the project root for full license information.
*/
#include <glib.h>
#include <mono/metadata/object.h>
#include <mono/metadata/object-internals.h>
+#define set_error_messagev() do { \
+ if (!(error->full_message = g_strdup_vprintf (msg_format, args))) \
+ error->flags |= MONO_ERROR_INCOMPLETE; \
+} while (0)
+
#define set_error_message() do { \
va_list args; \
va_start (args, msg_format); \
- if (!(error->full_message = g_strdup_vprintf (msg_format, args))) \
- error->flags |= MONO_ERROR_INCOMPLETE; \
+ set_error_messagev(); \
va_end (args); \
} while (0)
+static void
+mono_error_set_generic_errorv (MonoError *oerror, const char *name_space, const char *name, const char *msg_format, va_list args);
+
static gboolean
is_managed_exception (MonoErrorInternal *error)
{
}
void
-mono_error_set_generic_error (MonoError *oerror, const char * name_space, const char *name, const char *msg_format, ...)
+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_message ();
+ set_error_messagev ();
+}
+
+void
+mono_error_set_generic_error (MonoError *oerror, const char * name_space, const char *name, const char *msg_format, ...)
+{
+ va_list args;
+ va_start (args, msg_format);
+ mono_error_set_generic_errorv (oerror, name_space, name, msg_format, args);
+ va_end (args);
+}
+
+/**
+ * mono_error_set_not_implemented:
+ *
+ * System.NotImplementedException
+ */
+void
+mono_error_set_not_implemented (MonoError *oerror, const char *msg_format, ...)
+{
+ va_list args;
+ va_start (args, msg_format);
+ mono_error_set_generic_errorv (oerror, "System", "NotImplementedException", msg_format, args);
+ va_end (args);
+}
+
+/**
+ * mono_error_set_execution_engine:
+ *
+ * System.ExecutionEngineException
+ */
+void
+mono_error_set_execution_engine (MonoError *oerror, const char *msg_format, ...)
+{
+ va_list args;
+ va_start (args, msg_format);
+ mono_error_set_generic_errorv (oerror, "System", "ExecutionEngineException", msg_format, args);
+ va_end (args);
+}
+
+/**
+ * mono_error_set_execution_engine:
+ *
+ * System.NotSupportedException
+ */
+void
+mono_error_set_not_supported (MonoError *oerror, const char *msg_format, ...)
+{
+ va_list args;
+ va_start (args, msg_format);
+ mono_error_set_generic_errorv (oerror, "System", "NotSupportedException", msg_format, args);
+ va_end (args);
}
void
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");
+ mono_error_set_execution_engine (oerror, "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");
+ mono_error_set_execution_engine (oerror, "Runtime tried to produce a mono-error from a non-error loader-error");
break;
case MONO_EXCEPTION_INVALID_PROGRAM:
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);
+ mono_error_set_execution_engine (oerror, "Runtime tried to produce a mono-error from JIT internal error %d", loader_error->exception_type);
break;
case MONO_EXCEPTION_BAD_IMAGE:
break;
default:
- mono_error_set_generic_error (oerror, "System", "ExecutionEngineException", "Runtime tried to produce an unknown loader-error %d", loader_error->exception_type);
+ mono_error_set_execution_engine (oerror, "Runtime tried to produce an unknown loader-error %d", loader_error->exception_type);
break;
}
break;
case MONO_ERROR_TYPE_LOAD:
- if (error->type_name && error->assembly_name) {
+ if ((error->type_name && error->assembly_name) || error->exn.klass) {
type_name = get_type_name_as_mono_string (error, domain, error_out);
if (!mono_error_ok (error_out))
break;
}
case MONO_ERROR_GENERIC:
if (!error->exception_name_space || !error->exception_name)
- mono_error_set_generic_error (error_out, "System", "ExecutionEngineException", "MonoError with generic error but no exception name was supplied");
+ mono_error_set_execution_engine (error_out, "MonoError with generic error but no exception name was supplied");
else
exception = mono_exception_from_name_msg (mono_defaults.corlib, error->exception_name_space, error->exception_name, error->full_message);
break;
break;
default:
- mono_error_set_generic_error (error_out, "System", "ExecutionEngineException", "Invalid error-code %d", error->error_code);
+ mono_error_set_execution_engine (error_out, "Invalid error-code %d", error->error_code);
}
if (!mono_error_ok (error_out))