*
* Copyright 2001-2003 Ximian, Inc (http://www.ximian.com)
* Copyright 2004-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>
{
char *trace;
MonoString *res;
- if (!exc)
- mono_raise_exception (mono_get_exception_argument_null ("exception"));
+ if (!exc) {
+ mono_set_pending_exception (mono_get_exception_argument_null ("exception"));
+ return NULL;
+ }
trace = mono_exception_get_native_backtrace (exc);
res = mono_string_new (mono_domain_get (), trace);
mono_raise_exception (ex);
}
-void
+/**
+ * mono_error_set_pending_exception:
+ * @error: The error
+ *
+ *
+ * If @error is set, convert it to an exception and set the pending exception for the current icall.
+ * Returns TRUE if @error was set, or FALSE otherwise, so that you can write:
+ * if (mono_error_set_pending_exception (error)) {
+ * { ... cleanup code ... }
+ * return;
+ * }
+ */
+gboolean
mono_error_set_pending_exception (MonoError *error)
{
MonoException *ex = mono_error_convert_to_exception (error);
- if (ex)
+ if (ex) {
mono_set_pending_exception (ex);
+ return TRUE;
+ } else {
+ return FALSE;
+ }
}