+2009-04-17 Tom Hindle <tom_hindle@sil.org>
+
+ * Marshal.cs: Improved GetExceptionForHR to return real C# exceptions in
+ certain cases instead of always COMException.
+
2009-02-24 Sebastien Pouliot <sebastien@ximian.com>
* SafeHandle.cs: Add default ctor in 2.1 profile (needed to compile
internal
#endif
static Exception GetExceptionForHR (int errorCode, IntPtr errorInfo) {
+
+ const int E_OUTOFMEMORY = unchecked ((int)0x8007000EL);
+ const int E_INVALIDARG = unchecked ((int)0X80070057);
+
+ switch (errorCode)
+ {
+ case E_OUTOFMEMORY:
+ return new OutOfMemoryException ();
+ case E_INVALIDARG:
+ return new ArgumentException ();
+ }
if (errorCode < 0)
return new COMException ("", errorCode);
return null;
+2009-04-29 Jonathan Chambers <joncham@gmail.com>
+
+ * MarshalTest.cs: Add test for GetExceptionForHR.
+
2008-06-21 Gert Driesen <drieseng@users.sourceforge.net>
* MarshalTest.cs: Added tests for GetHINSTANCE. Improved existing
Marshal.FreeHGlobal (mem);
}
+ [Test]
+ public void TestGetExceptionForHR ()
+ {
+ const int E_OUTOFMEMORY = unchecked ((int) 0x8007000E);
+ const int E_INVALIDARG = unchecked ((int) 0X80070057);
+
+ Exception ex = Marshal.GetExceptionForHR (E_OUTOFMEMORY);
+ Assert.AreEqual (typeof (OutOfMemoryException), ex.GetType (), "E_OUTOFMEMORY");
+
+ ex = Marshal.GetExceptionForHR (E_INVALIDARG);
+ Assert.AreEqual (typeof (ArgumentException), ex.GetType (), "E_INVALIDARG");
+ }
+
bool RunningOnUnix {
get {
int p = (int) Environment.OSVersion.Platform;