diff --git a/runtime/runtime.m b/runtime/runtime.m index 5aa986f489..e0443a5ee0 100644 --- a/runtime/runtime.m +++ b/runtime/runtime.m @@ -2366,16 +2366,13 @@ xamarin_process_managed_exception (MonoObject *exception) xamarin_free (fullname); } - char *message = xamarin_get_exception_message (handle, &exception_gchandle); + reason = xamarin_print_all_exceptions (handle); if (exception_gchandle != INVALID_GCHANDLE) { PRINT (PRODUCT ": Got an exception when trying to get the message for an exception (this exception will be ignored):"); PRINT ("%@", xamarin_print_all_exceptions (exception_gchandle)); xamarin_gchandle_free (exception_gchandle); exception_gchandle = INVALID_GCHANDLE; reason = @"Unknown message"; - } else { - reason = [NSString stringWithUTF8String: message]; - xamarin_free (message); } userInfo = [NSDictionary dictionaryWithObject: [XamarinGCHandle createWithHandle: handle] forKey: @"XamarinManagedExceptionHandle"]; diff --git a/tests/monotouch-test/ObjCRuntime/ExceptionsTest.cs b/tests/monotouch-test/ObjCRuntime/ExceptionsTest.cs index 3b8d761aa0..886689543f 100644 --- a/tests/monotouch-test/ObjCRuntime/ExceptionsTest.cs +++ b/tests/monotouch-test/ObjCRuntime/ExceptionsTest.cs @@ -154,7 +154,7 @@ namespace MonoTouchFixtures.ObjCRuntime { thrownException = ex; } Assert.AreSame (e.Exception, thrownException, "exception"); - Assert.AreEqual ("3,14", thrownException.Message, "1 thrown message"); + Assert.That (thrownException.Message, Does.StartWith ("3,14"), "1 thrown message"); Assert.AreSame (typeof (ApplicationException), thrownException.GetType (), "1 thrown type"); if (hasDebugger) { Assert.AreEqual (0, objcEventArgs.Count, "1 objc exception"); @@ -162,7 +162,7 @@ namespace MonoTouchFixtures.ObjCRuntime { Assert.AreEqual (1, objcEventArgs.Count, "1 objc exception"); Assert.AreEqual (defaultObjectiveCExceptionMode, objcEventArgs [0].ExceptionMode, "1 objc mode"); Assert.AreEqual ("System.ApplicationException", objcEventArgs [0].Exception.Name, "1 objc reason"); - Assert.AreEqual ("3,14", objcEventArgs [0].Exception.Reason, "1 objc message"); + Assert.That (objcEventArgs [0].Exception.Reason, Does.StartWith ("3,14"), "1 objc message"); } if (hasDebugger) { Assert.AreEqual (0, managedEventArgs.Count, "1 managed count"); @@ -187,7 +187,7 @@ namespace MonoTouchFixtures.ObjCRuntime { Assert.AreNotSame (e.Exception, thrownException, "exception"); Assert.AreSame (typeof (ObjCException), thrownException.GetType (), "2 thrown type"); Assert.AreEqual ("Caught exception", ((ObjCException) thrownException).Name, "2 thrown name"); - Assert.AreEqual ("exception was rethrown", ((ObjCException) thrownException).Reason, "2 thrown reason"); + Assert.That (((ObjCException) thrownException).Reason, Does.StartWith ("exception was rethrown") , "2 thrown reason"); } if (hasDebugger) { Assert.AreEqual (0, objcEventArgs.Count, "2 objc exception"); @@ -195,7 +195,7 @@ namespace MonoTouchFixtures.ObjCRuntime { Assert.AreEqual (1, objcEventArgs.Count, "2 objc exception"); Assert.AreEqual (defaultObjectiveCExceptionMode, objcEventArgs [0].ExceptionMode, "2 objc mode"); Assert.AreEqual ("Caught exception", objcEventArgs [0].Exception.Name, "2 objc reason"); - Assert.AreEqual ("exception was rethrown", objcEventArgs [0].Exception.Reason, "2 objc message"); + Assert.That (objcEventArgs [0].Exception.Reason, Does.StartWith ("exception was rethrown"), "2 objc message"); } if (hasDebugger) { Assert.AreEqual (0, managedEventArgs.Count, "2 managed count");