Add inner exception support with ideas from Tamas Szekeres
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@8933 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
a4d5f4a992
commit
214a1839ee
1 changed files with 15 additions and 13 deletions
|
|
@ -162,43 +162,47 @@ SWIGEXPORT void SWIGSTDCALL SWIGRegisterExceptionArgumentCallbacks_$module(
|
||||||
ExceptionArgumentDelegate argumentOutOfRangeDelegate);
|
ExceptionArgumentDelegate argumentOutOfRangeDelegate);
|
||||||
|
|
||||||
static void SetPendingApplicationException(string message) {
|
static void SetPendingApplicationException(string message) {
|
||||||
SWIGPendingException.Set(new System.ApplicationException(message));
|
SWIGPendingException.Set(new System.ApplicationException(message, SWIGPendingException.Retrieve()));
|
||||||
}
|
}
|
||||||
static void SetPendingArithmeticException(string message) {
|
static void SetPendingArithmeticException(string message) {
|
||||||
SWIGPendingException.Set(new System.ArithmeticException(message));
|
SWIGPendingException.Set(new System.ArithmeticException(message, SWIGPendingException.Retrieve()));
|
||||||
}
|
}
|
||||||
static void SetPendingDivideByZeroException(string message) {
|
static void SetPendingDivideByZeroException(string message) {
|
||||||
SWIGPendingException.Set(new System.DivideByZeroException(message));
|
SWIGPendingException.Set(new System.DivideByZeroException(message, SWIGPendingException.Retrieve()));
|
||||||
}
|
}
|
||||||
static void SetPendingIndexOutOfRangeException(string message) {
|
static void SetPendingIndexOutOfRangeException(string message) {
|
||||||
SWIGPendingException.Set(new System.IndexOutOfRangeException(message));
|
SWIGPendingException.Set(new System.IndexOutOfRangeException(message, SWIGPendingException.Retrieve()));
|
||||||
}
|
}
|
||||||
static void SetPendingInvalidOperationException(string message) {
|
static void SetPendingInvalidOperationException(string message) {
|
||||||
SWIGPendingException.Set(new System.InvalidOperationException(message));
|
SWIGPendingException.Set(new System.InvalidOperationException(message, SWIGPendingException.Retrieve()));
|
||||||
}
|
}
|
||||||
static void SetPendingIOException(string message) {
|
static void SetPendingIOException(string message) {
|
||||||
SWIGPendingException.Set(new System.IO.IOException(message));
|
SWIGPendingException.Set(new System.IO.IOException(message, SWIGPendingException.Retrieve()));
|
||||||
}
|
}
|
||||||
static void SetPendingNullReferenceException(string message) {
|
static void SetPendingNullReferenceException(string message) {
|
||||||
SWIGPendingException.Set(new System.NullReferenceException(message));
|
SWIGPendingException.Set(new System.NullReferenceException(message, SWIGPendingException.Retrieve()));
|
||||||
}
|
}
|
||||||
static void SetPendingOutOfMemoryException(string message) {
|
static void SetPendingOutOfMemoryException(string message) {
|
||||||
SWIGPendingException.Set(new System.OutOfMemoryException(message));
|
SWIGPendingException.Set(new System.OutOfMemoryException(message, SWIGPendingException.Retrieve()));
|
||||||
}
|
}
|
||||||
static void SetPendingOverflowException(string message) {
|
static void SetPendingOverflowException(string message) {
|
||||||
SWIGPendingException.Set(new System.OverflowException(message));
|
SWIGPendingException.Set(new System.OverflowException(message, SWIGPendingException.Retrieve()));
|
||||||
}
|
}
|
||||||
static void SetPendingSystemException(string message) {
|
static void SetPendingSystemException(string message) {
|
||||||
SWIGPendingException.Set(new System.SystemException(message));
|
SWIGPendingException.Set(new System.SystemException(message, SWIGPendingException.Retrieve()));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void SetPendingArgumentException(string message, string paramName) {
|
static void SetPendingArgumentException(string message, string paramName) {
|
||||||
SWIGPendingException.Set(new System.ArgumentException(message, paramName));
|
SWIGPendingException.Set(new System.ArgumentException(message, paramName, SWIGPendingException.Retrieve()));
|
||||||
}
|
}
|
||||||
static void SetPendingArgumentNullException(string message, string paramName) {
|
static void SetPendingArgumentNullException(string message, string paramName) {
|
||||||
|
Exception e = SWIGPendingException.Retrieve();
|
||||||
|
if (e != null) message = message + " Inner Exception: " + e.Message;
|
||||||
SWIGPendingException.Set(new System.ArgumentNullException(paramName, message));
|
SWIGPendingException.Set(new System.ArgumentNullException(paramName, message));
|
||||||
}
|
}
|
||||||
static void SetPendingArgumentOutOfRangeException(string message, string paramName) {
|
static void SetPendingArgumentOutOfRangeException(string message, string paramName) {
|
||||||
|
Exception e = SWIGPendingException.Retrieve();
|
||||||
|
if (e != null) message = message + " Inner Exception: " + e.Message;
|
||||||
SWIGPendingException.Set(new System.ArgumentOutOfRangeException(paramName, message));
|
SWIGPendingException.Set(new System.ArgumentOutOfRangeException(paramName, message));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -240,8 +244,6 @@ SWIGEXPORT void SWIGSTDCALL SWIGRegisterExceptionArgumentCallbacks_$module(
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void Set(Exception e) {
|
public static void Set(Exception e) {
|
||||||
if (pendingException != null)
|
|
||||||
throw new ApplicationException("FATAL: An earlier pending exception from unmanaged code was missed and thus not thrown (" + pendingException.ToString() + ")", e);
|
|
||||||
pendingException = e;
|
pendingException = e;
|
||||||
lock(typeof($imclassname)) {
|
lock(typeof($imclassname)) {
|
||||||
numExceptionsPending++;
|
numExceptionsPending++;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue