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