X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=blobdiff_plain;f=mono%2Futils%2Fmono-error.c;h=94c0c4fd35a29639b9d692e08a9d7ce32d4ffbe8;hb=ef0ddf45c3081e799edcb4e95770186514b80cf1;hp=b6f2ee0979524b82e12815c5bd57731c7d1886a4;hpb=a341404ecdd3b5ca2ed0ab1e9a5bcb9b5ccd2566;p=mono.git diff --git a/mono/utils/mono-error.c b/mono/utils/mono-error.c index b6f2ee09795..94c0c4fd35a 100644 --- a/mono/utils/mono-error.c +++ b/mono/utils/mono-error.c @@ -4,6 +4,7 @@ * 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 @@ -16,14 +17,21 @@ #include #include +#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) { @@ -332,14 +340,65 @@ mono_error_set_bad_image (MonoError *oerror, MonoImage *image, const char *msg_f } 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 @@ -362,13 +421,13 @@ mono_error_set_from_loader_error (MonoError *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"); + 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: @@ -409,7 +468,7 @@ mono_error_set_from_loader_error (MonoError *oerror) 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: @@ -421,7 +480,7 @@ mono_error_set_from_loader_error (MonoError *oerror) 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; } @@ -683,7 +742,7 @@ mono_error_prepare_exception (MonoError *oerror, MonoError *error_out) } 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; @@ -693,7 +752,7 @@ mono_error_prepare_exception (MonoError *oerror, MonoError *error_out) 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))