From dbb7096b0562bbd95e3bdc8aae589ef47ab35461 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 29 Aug 2003 20:05:15 +0000 Subject: [PATCH] Support for throwing C# exceptions from C/C++ git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@5019 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Lib/exception.i | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/Lib/exception.i b/Lib/exception.i index 0c8bad2c9..48333a21c 100644 --- a/Lib/exception.i +++ b/Lib/exception.i @@ -268,4 +268,37 @@ static void _SWIG_exception(int code, const char *msg) { %} #endif +#ifdef SWIGCSHARP +%{ +static void SWIG_exception(int code, const char *msg) { + SWIG_CSharpExceptionCodes exception_code = SWIG_CSharpException; + switch(code) { + case SWIG_MemoryError: + exception_code = SWIG_CSharpOutOfMemoryException; + break; + case SWIG_IndexError: + exception_code = SWIG_CSharpIndexOutOfRangeException; + break; + case SWIG_DivisionByZero: + exception_code = SWIG_CSharpDivideByZeroException; + break; + case SWIG_ValueError: + exception_code = SWIG_CSharpArgumentOutOfRangeException; + break; + case SWIG_IOError: + case SWIG_RuntimeError: + case SWIG_TypeError: + case SWIG_OverflowError: + case SWIG_SyntaxError: + case SWIG_SystemError: + case SWIG_UnknownError: + default: + exception_code = SWIG_CSharpException; + break; + } + SWIG_CSharpThrowException(exception_code, msg); +} +%} +#endif // SWIGCSHARP + /* exception.i ends here */