コード例 #1
0
ファイル: mono-error.c プロジェクト: mono/mono
/*
Convert this MonoError to an exception if it's faulty or return NULL.
The error object is cleant after.
*/
MonoException*
mono_error_convert_to_exception (MonoError *target_error)
{
	ERROR_DECL (error);
	MonoException *ex;

	/* Mempool stored error shouldn't be cleaned up */
	g_assert (!is_boxed ((MonoErrorInternal*)target_error));

	if (mono_error_ok (target_error))
		return NULL;

	ex = mono_error_prepare_exception (target_error, error);
	if (!mono_error_ok (error)) {
		ERROR_DECL (second_chance);
		/*Try to produce the exception for the second error. FIXME maybe we should log about the original one*/
		ex = mono_error_prepare_exception (error, second_chance);

		// We cannot reasonably handle double faults, maybe later.
		g_assert (mono_error_ok (second_chance));
		mono_error_cleanup (error);
	}
	mono_error_cleanup (target_error);
	return ex;
}
コード例 #2
0
ファイル: mono-error.c プロジェクト: mono/mono
static MonoExceptionHandle
mono_error_prepare_exception_handle (MonoError *oerror, MonoError *error_out)
// Can fail with out-of-memory
{
	HANDLE_FUNCTION_ENTER ();
	MonoExceptionHandle ex = MONO_HANDLE_NEW (MonoException, mono_error_prepare_exception (oerror, error_out));
	HANDLE_FUNCTION_RETURN_REF (MonoException, ex);
}
コード例 #3
0
ファイル: mono-error.c プロジェクト: Appercode/mono
MonoException*
mono_error_convert_to_exception (MonoError *target_error)
{
	MonoError error;
	MonoException *ex;

	if (mono_error_ok (target_error))
		return NULL;

	ex = mono_error_prepare_exception (target_error, &error);
	if (!mono_error_ok (&error)) {
		MonoError second_chance;
		/*Try to produce the exception for the second error. FIXME maybe we should log about the original one*/
		ex = mono_error_prepare_exception (&error, &second_chance);

		g_assert (mono_error_ok (&second_chance)); /*We can't reasonable handle double faults, maybe later.*/
		mono_error_cleanup (&error);
	}
	mono_error_cleanup (target_error);
	return ex;
}