pyerrors.swg 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. /* -----------------------------------------------------------------------------
  2. * error manipulation
  3. * ----------------------------------------------------------------------------- */
  4. SWIGRUNTIME PyObject*
  5. SWIG_Python_ErrorType(int code) {
  6. PyObject* type = 0;
  7. switch(code) {
  8. case SWIG_MemoryError:
  9. type = PyExc_MemoryError;
  10. break;
  11. case SWIG_IOError:
  12. type = PyExc_IOError;
  13. break;
  14. case SWIG_RuntimeError:
  15. type = PyExc_RuntimeError;
  16. break;
  17. case SWIG_IndexError:
  18. type = PyExc_IndexError;
  19. break;
  20. case SWIG_TypeError:
  21. type = PyExc_TypeError;
  22. break;
  23. case SWIG_DivisionByZero:
  24. type = PyExc_ZeroDivisionError;
  25. break;
  26. case SWIG_OverflowError:
  27. type = PyExc_OverflowError;
  28. break;
  29. case SWIG_SyntaxError:
  30. type = PyExc_SyntaxError;
  31. break;
  32. case SWIG_ValueError:
  33. type = PyExc_ValueError;
  34. break;
  35. case SWIG_SystemError:
  36. type = PyExc_SystemError;
  37. break;
  38. case SWIG_AttributeError:
  39. type = PyExc_AttributeError;
  40. break;
  41. default:
  42. type = PyExc_RuntimeError;
  43. }
  44. return type;
  45. }
  46. SWIGRUNTIME void
  47. SWIG_Python_AddErrorMsg(const char* mesg)
  48. {
  49. PyObject *type = 0;
  50. PyObject *value = 0;
  51. PyObject *traceback = 0;
  52. if (PyErr_Occurred()) PyErr_Fetch(&type, &value, &traceback);
  53. if (value) {
  54. char *tmp;
  55. PyObject *old_str = PyObject_Str(value);
  56. PyErr_Clear();
  57. Py_XINCREF(type);
  58. PyErr_Format(type, "%s %s", tmp = SWIG_Python_str_AsChar(old_str), mesg);
  59. SWIG_Python_str_DelForPy3(tmp);
  60. Py_DECREF(old_str);
  61. Py_DECREF(value);
  62. } else {
  63. PyErr_SetString(PyExc_RuntimeError, mesg);
  64. }
  65. }