// This SWIG library file provides language independent exception handling
#define SWIG_MemoryError 1
#define SWIG_RuntimeError 3
#define SWIG_IndexError 4
#define SWIG_DivisionByZero 6
#define SWIG_OverflowError 7
#define SWIG_SyntaxError 8
#define SWIG_ValueError 9
#define SWIG_SystemError 10
#define SWIG_UnknownError 99
/* We cast from 'const char*' to 'char*' since TCL_VOLATILE ensure
that an internal copy of the strng will be stored.
NOTE: Later use const_cast<char*> via SWIG_const_cast or so.
#define SWIG_exception(a,b) { Tcl_SetResult(interp,(char *)b,TCL_VOLATILE); SWIG_fail; }
#define SWIG_exception(a,b) { Tcl_SetResult(interp,(char *)b,TCL_VOLATILE); return TCL_ERROR; }
#define SWIG_exception(a,b) SWIG_croak(b)
/* We should make use of "code" if we can */
#define SWIG_exception(code, msg) { zend_error(E_ERROR, msg); }
SWIGINTERN void SWIG_exception_(int code, const char *msg) {
PyErr_SetString(PyExc_MemoryError,msg);
PyErr_SetString(PyExc_IOError,msg);
PyErr_SetString(PyExc_RuntimeError,msg);
PyErr_SetString(PyExc_IndexError,msg);
PyErr_SetString(PyExc_TypeError,msg);
case SWIG_DivisionByZero:
PyErr_SetString(PyExc_ZeroDivisionError,msg);
PyErr_SetString(PyExc_OverflowError,msg);
PyErr_SetString(PyExc_SyntaxError,msg);
PyErr_SetString(PyExc_ValueError,msg);
PyErr_SetString(PyExc_SystemError,msg);
PyErr_SetString(PyExc_RuntimeError,msg);
#define SWIG_exception(a,b) { SWIG_exception_(a,b); SWIG_fail; }
SWIGINTERN void SWIG_exception_ (int code, const char *msg,
scm_error(gh_symbol2scm((char *) (scmerr)), \
(char *) subr, (char *) msg, \
#define MAP(swigerr, scmerr) \
MAP(SWIG_MemoryError, "swig-memory-error");
MAP(SWIG_IOError, "swig-io-error");
MAP(SWIG_RuntimeError, "swig-runtime-error");
MAP(SWIG_IndexError, "swig-index-error");
MAP(SWIG_TypeError, "swig-type-error");
MAP(SWIG_DivisionByZero, "swig-division-by-zero");
MAP(SWIG_OverflowError, "swig-overflow-error");
MAP(SWIG_SyntaxError, "swig-syntax-error");
MAP(SWIG_ValueError, "swig-value-error");
MAP(SWIG_SystemError, "swig-system-error");
#define SWIG_exception(a,b) SWIG_exception_(a, b, FUNC_NAME)
SWIGINTERN void SWIG_exception_ (int code, const char *msg) {
scheme_signal_error(errname " (%s)", msg);
#define MAP(swigerr, errname) \
MAP(SWIG_MemoryError, "swig-memory-error");
MAP(SWIG_IOError, "swig-io-error");
MAP(SWIG_RuntimeError, "swig-runtime-error");
MAP(SWIG_IndexError, "swig-index-error");
MAP(SWIG_TypeError, "swig-type-error");
MAP(SWIG_DivisionByZero, "swig-division-by-zero");
MAP(SWIG_OverflowError, "swig-overflow-error");
MAP(SWIG_SyntaxError, "swig-syntax-error");
MAP(SWIG_ValueError, "swig-value-error");
MAP(SWIG_SystemError, "swig-system-error");
#define SWIG_exception(a,b) SWIG_exception_(a, b)
SWIGINTERN void SWIG_JavaException(JNIEnv *jenv, int code, const char *msg) {
SWIG_JavaExceptionCodes exception_code = SWIG_JavaUnknownError;
exception_code = SWIG_JavaOutOfMemoryError;
exception_code = SWIG_JavaIOException;
exception_code = SWIG_JavaRuntimeException;
exception_code = SWIG_JavaIndexOutOfBoundsException;
case SWIG_DivisionByZero:
exception_code = SWIG_JavaArithmeticException;
exception_code = SWIG_JavaIllegalArgumentException;
exception_code = SWIG_JavaUnknownError;
SWIG_JavaThrowException(jenv, exception_code, msg);
%define SWIG_exception(code, msg)
SWIG_JavaException(jenv, code, msg);
#define OCAML_MSG_BUF_LEN 1024
SWIGINTERN void SWIG_exception_(int code, const char *msg) {
char msg_buf[OCAML_MSG_BUF_LEN];
sprintf( msg_buf, "Exception(%d): %s\n", code, msg );
#define SWIG_exception(a,b) SWIG_exception_((a),(b))
SWIGINTERN void SWIG_exception_(int code, const char *msg) {
rb_raise(rb_eNoMemError, msg);
rb_raise(rb_eIOError, msg);
rb_raise(rb_eRuntimeError, msg);
rb_raise(rb_eIndexError, msg);
rb_raise(rb_eTypeError, msg);
case SWIG_DivisionByZero:
rb_raise(rb_eZeroDivError, msg);
rb_raise(rb_eRangeError, msg);
rb_raise(rb_eSyntaxError, msg);
rb_raise(rb_eArgError, msg);
rb_raise(rb_eFatal, msg);
rb_raise(rb_eRuntimeError, msg);
#define SWIG_exception(a, b) SWIG_exception_((a), (b))
SWIGINTERN void SWIG_exception_(int code, const char *msg) {
a = C_alloc (C_SIZEOF_STRING (strlen (msg)) + C_SIZEOF_LIST(2));
scmmsg = C_string2 (&a, (char *) msg);
list = C_list(&a, 2, C_fix(code), scmmsg);
SWIG_ThrowException(list);
#define SWIG_exception(a,b) SWIG_exception_((a),(b))
SWIGINTERN void SWIG_CSharpException(int code, const char *msg) {
if (code == SWIG_ValueError) {
SWIG_CSharpExceptionArgumentCodes exception_code = SWIG_CSharpArgumentOutOfRangeException;
SWIG_CSharpSetPendingExceptionArgument(exception_code, msg, 0);
SWIG_CSharpExceptionCodes exception_code = SWIG_CSharpApplicationException;
exception_code = SWIG_CSharpOutOfMemoryException;
exception_code = SWIG_CSharpIndexOutOfRangeException;
case SWIG_DivisionByZero:
exception_code = SWIG_CSharpDivideByZeroException;
exception_code = SWIG_CSharpIOException;
exception_code = SWIG_CSharpOverflowException;
exception_code = SWIG_CSharpApplicationException;
SWIG_CSharpSetPendingException(exception_code, msg);
%define SWIG_exception(code, msg)
SWIG_CSharpException(code, msg);
#define SWIG_exception(a,b)\
{ lua_pushfstring(L,"%s:%s",#a,b);SWIG_fail; }
You can use the SWIG_CATCH_STDEXCEPT macro with the %exception
SWIG_CATCH_STDEXCEPT // catch std::exception
SWIG_exception(SWIG_UnknownError, "Unknown exception");
%define SWIG_CATCH_STDEXCEPT
/* catching std::exception */
catch (std::invalid_argument& e) {
SWIG_exception(SWIG_ValueError, e.what() );
} catch (std::domain_error& e) {
SWIG_exception(SWIG_ValueError, e.what() );
} catch (std::overflow_error& e) {
SWIG_exception(SWIG_OverflowError, e.what() );
} catch (std::out_of_range& e) {
SWIG_exception(SWIG_IndexError, e.what() );
} catch (std::length_error& e) {
SWIG_exception(SWIG_IndexError, e.what() );
} catch (std::runtime_error& e) {
SWIG_exception(SWIG_RuntimeError, e.what() );
} catch (std::exception& e) {
SWIG_exception(SWIG_SystemError, e.what() );
%define SWIG_CATCH_UNKNOWN
catch (std::exception& e) {
SWIG_exception(SWIG_SystemError, e.what() );
SWIG_exception(SWIG_UnknownError, "unknown exception");
/* exception.i ends here */