PageRenderTime 53ms CodeModel.GetById 19ms RepoModel.GetById 1ms app.codeStats 0ms

/src/error.c

https://github.com/eagles125/pyuv
C | 68 lines | 62 code | 6 blank | 0 comment | 2 complexity | 8e2e1d7fa536c51573902525d1d28d0a MD5 | raw file
  1. #ifdef PYUV_PYTHON3
  2. static PyModuleDef pyuv_error_module = {
  3. PyModuleDef_HEAD_INIT,
  4. "pyuv.error", /*m_name*/
  5. NULL, /*m_doc*/
  6. -1, /*m_size*/
  7. NULL, /*m_methods*/
  8. };
  9. #endif
  10. PyObject *
  11. init_error(void)
  12. {
  13. PyObject *module;
  14. #ifdef PYUV_PYTHON3
  15. module = PyModule_Create(&pyuv_error_module);
  16. #else
  17. module = Py_InitModule("pyuv.error", NULL);
  18. #endif
  19. if (module == NULL) {
  20. return NULL;
  21. }
  22. PyExc_UVError = PyErr_NewException("pyuv.error.UVError", NULL, NULL);
  23. PyExc_ThreadError = PyErr_NewException("pyuv.error.ThreadError", PyExc_UVError, NULL);
  24. PyExc_HandleError = PyErr_NewException("pyuv.error.HandleError", PyExc_UVError, NULL);
  25. PyExc_HandleClosedError = PyErr_NewException("pyuv.error.HandleClosedError", PyExc_HandleError, NULL);
  26. PyExc_AsyncError = PyErr_NewException("pyuv.error.AsyncError", PyExc_HandleError, NULL);
  27. PyExc_TimerError = PyErr_NewException("pyuv.error.TimerError", PyExc_HandleError, NULL);
  28. PyExc_PrepareError = PyErr_NewException("pyuv.error.PrepareError", PyExc_HandleError, NULL);
  29. PyExc_IdleError = PyErr_NewException("pyuv.error.IdleError", PyExc_HandleError, NULL);
  30. PyExc_CheckError = PyErr_NewException("pyuv.error.CheckError", PyExc_HandleError, NULL);
  31. PyExc_SignalError = PyErr_NewException("pyuv.error.SignalError", PyExc_HandleError, NULL);
  32. PyExc_StreamError = PyErr_NewException("pyuv.error.StreamError", PyExc_HandleError, NULL);
  33. PyExc_TCPError = PyErr_NewException("pyuv.error.TCPError", PyExc_StreamError, NULL);
  34. PyExc_PipeError = PyErr_NewException("pyuv.error.PipeError", PyExc_StreamError, NULL);
  35. PyExc_TTYError = PyErr_NewException("pyuv.error.TTYError", PyExc_StreamError, NULL);
  36. PyExc_UDPError = PyErr_NewException("pyuv.error.UDPError", PyExc_HandleError, NULL);
  37. PyExc_PollError = PyErr_NewException("pyuv.error.PollError", PyExc_HandleError, NULL);
  38. PyExc_FSError = PyErr_NewException("pyuv.error.FSError", PyExc_UVError, NULL);
  39. PyExc_FSEventError = PyErr_NewException("pyuv.error.FSEventError", PyExc_HandleError, NULL);
  40. PyExc_FSPollError = PyErr_NewException("pyuv.error.FSPollError", PyExc_HandleError, NULL);
  41. PyExc_ProcessError = PyErr_NewException("pyuv.error.ProcessError", PyExc_HandleError, NULL);
  42. PyUVModule_AddType(module, "UVError", (PyTypeObject *)PyExc_UVError);
  43. PyUVModule_AddType(module, "ThreadError", (PyTypeObject *)PyExc_ThreadError);
  44. PyUVModule_AddType(module, "HandleError", (PyTypeObject *)PyExc_HandleError);
  45. PyUVModule_AddType(module, "AsyncError", (PyTypeObject *)PyExc_AsyncError);
  46. PyUVModule_AddType(module, "TimerError", (PyTypeObject *)PyExc_TimerError);
  47. PyUVModule_AddType(module, "PrepareError", (PyTypeObject *)PyExc_PrepareError);
  48. PyUVModule_AddType(module, "IdleError", (PyTypeObject *)PyExc_IdleError);
  49. PyUVModule_AddType(module, "CheckError", (PyTypeObject *)PyExc_CheckError);
  50. PyUVModule_AddType(module, "SignalError", (PyTypeObject *)PyExc_SignalError);
  51. PyUVModule_AddType(module, "StreamError", (PyTypeObject *)PyExc_StreamError);
  52. PyUVModule_AddType(module, "TCPError", (PyTypeObject *)PyExc_TCPError);
  53. PyUVModule_AddType(module, "PipeError", (PyTypeObject *)PyExc_PipeError);
  54. PyUVModule_AddType(module, "TTYError", (PyTypeObject *)PyExc_TTYError);
  55. PyUVModule_AddType(module, "UDPError", (PyTypeObject *)PyExc_UDPError);
  56. PyUVModule_AddType(module, "PollError", (PyTypeObject *)PyExc_PollError);
  57. PyUVModule_AddType(module, "FSError", (PyTypeObject *)PyExc_FSError);
  58. PyUVModule_AddType(module, "FSEventError", (PyTypeObject *)PyExc_FSEventError);
  59. PyUVModule_AddType(module, "FSPollError", (PyTypeObject *)PyExc_FSPollError);
  60. PyUVModule_AddType(module, "ProcessError", (PyTypeObject *)PyExc_ProcessError);
  61. return module;
  62. }