static MonoExceptionHandle mono_exception_new_argument_internal (const char *type, const char *arg, const char *msg, MonoError *error) { MonoExceptionHandle ex = mono_exception_new_by_name_msg (mono_get_corlib (), "System", type, msg, error); if (arg && !MONO_HANDLE_IS_NULL (ex)) { MonoArgumentExceptionHandle argex = MONO_HANDLE_CAST (MonoArgumentException, ex); MonoStringHandle arg_str = mono_string_new_handle (MONO_HANDLE_DOMAIN (ex), arg, error); MONO_HANDLE_SET (argex, param_name, arg_str); } return ex; }
/** * mono_exception_new_by_name_msg: * \param image the Mono image where to look for the class * \param name_space the namespace for the class * \param name class name * \param msg the message to embed inside the exception * * Creates an exception and initializes its message field. * * \returns the initialized exception instance. */ MonoExceptionHandle mono_exception_new_by_name_msg (MonoImage *image, const char *name_space, const char *name, const char *msg, MonoError *error) { HANDLE_FUNCTION_ENTER (); MonoExceptionHandle ex = mono_exception_new_by_name (image, name_space, name, error); goto_if_nok (error, return_null); if (msg) { MonoStringHandle msg_str = mono_string_new_handle (MONO_HANDLE_DOMAIN (ex), msg, error); // FIXME? Maybe just ignore this error, the exception is close to correct. goto_if_nok (error, return_null); // ex->message = msg_str; MONO_HANDLE_SET (ex, message, msg_str); } goto exit; return_null: MONO_HANDLE_ASSIGN (ex, NULL_HANDLE); exit: HANDLE_FUNCTION_RETURN_REF (MonoException, ex) }
static MonoExceptionHandle mono_exception_new_argument_internal (const char *type, const char *arg, const char *msg, MonoError *error) { #ifdef ENABLE_NETCORE MonoStringHandle arg_str = arg ? mono_string_new_handle (mono_domain_get (), arg, error) : NULL_HANDLE_STRING; MonoStringHandle msg_str = msg ? mono_string_new_handle (mono_domain_get (), msg, error) : NULL_HANDLE_STRING; if (!strcmp (type, "ArgumentException")) return mono_exception_from_name_two_strings_checked (mono_get_corlib (), "System", type, msg_str, arg_str, error); else return mono_exception_from_name_two_strings_checked (mono_get_corlib (), "System", type, arg_str, msg_str, error); #else MonoExceptionHandle ex = mono_exception_new_by_name_msg (mono_get_corlib (), "System", type, msg, error); if (arg && !MONO_HANDLE_IS_NULL (ex)) { MonoArgumentExceptionHandle argex = MONO_HANDLE_CAST (MonoArgumentException, ex); MonoStringHandle arg_str = mono_string_new_handle (MONO_HANDLE_DOMAIN (ex), arg, error); MONO_HANDLE_SET (argex, param_name, arg_str); } return ex; #endif }