1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112
|
/* -----------------------------------------------------------------------------
* error manipulation
* ----------------------------------------------------------------------------- */
SWIGRUNTIME PyObject*
SWIG_Python_ErrorType(int code) {
PyObject* type = 0;
switch(code) {
case SWIG_MemoryError:
type = PyExc_MemoryError;
break;
case SWIG_IOError:
type = PyExc_IOError;
break;
case SWIG_RuntimeError:
type = PyExc_RuntimeError;
break;
case SWIG_IndexError:
type = PyExc_IndexError;
break;
case SWIG_TypeError:
type = PyExc_TypeError;
break;
case SWIG_DivisionByZero:
type = PyExc_ZeroDivisionError;
break;
case SWIG_OverflowError:
type = PyExc_OverflowError;
break;
case SWIG_SyntaxError:
type = PyExc_SyntaxError;
break;
case SWIG_ValueError:
type = PyExc_ValueError;
break;
case SWIG_SystemError:
type = PyExc_SystemError;
break;
case SWIG_AttributeError:
type = PyExc_AttributeError;
break;
case SWIG_NullReferenceError:
type = PyExc_TypeError;
break;
default:
type = PyExc_RuntimeError;
}
return type;
}
SWIGRUNTIME void
SWIG_Python_AddErrorMsg(const char* mesg)
{
PyObject *type = 0;
PyObject *value = 0;
PyObject *traceback = 0;
if (PyErr_Occurred())
PyErr_Fetch(&type, &value, &traceback);
if (value) {
PyObject *old_str = PyObject_Str(value);
PyObject *bytes = NULL;
const char *tmp = SWIG_PyUnicode_AsUTF8AndSize(old_str, NULL, &bytes);
PyErr_Clear();
SWIG_Py_XINCREF(type);
if (tmp)
PyErr_Format(type, "%s %s", tmp, mesg);
else
PyErr_Format(type, "%s", mesg);
SWIG_Py_XDECREF(bytes);
SWIG_Py_DECREF(old_str);
SWIG_Py_DECREF(value);
} else {
PyErr_SetString(PyExc_RuntimeError, mesg);
}
}
SWIGRUNTIME int
SWIG_Python_TypeErrorOccurred(PyObject *obj)
{
PyObject *error;
if (obj)
return 0;
error = PyErr_Occurred();
return error && PyErr_GivenExceptionMatches(error, PyExc_TypeError);
}
SWIGRUNTIME void
SWIG_Python_RaiseOrModifyTypeError(const char *message)
{
if (SWIG_Python_TypeErrorOccurred(NULL)) {
/* Use existing TypeError to preserve stacktrace and enhance with given message */
PyObject *newvalue;
PyObject *type = NULL, *value = NULL, *traceback = NULL;
PyErr_Fetch(&type, &value, &traceback);
#if PY_VERSION_HEX >= 0x03000000
newvalue = PyUnicode_FromFormat("%S\nAdditional information:\n%s", value, message);
#else
newvalue = PyString_FromFormat("%s\nAdditional information:\n%s", PyString_AsString(value), message);
#endif
if (newvalue) {
SWIG_Py_XDECREF(value);
PyErr_Restore(type, newvalue, traceback);
} else {
PyErr_Restore(type, value, traceback);
}
} else {
/* Raise TypeError using given message */
PyErr_SetString(PyExc_TypeError, message);
}
}
|