python: create NTSTATUSError, HRESULTError and WERRORError
[amitay/samba.git] / python / pyglue.c
index 81244a249734aae536964916378550bb36719f3b..938a9f0ecf473c1b94726b3e37636b68e3c6489c 100644 (file)
@@ -24,6 +24,9 @@
 #include "lib/socket/netif.h"
 
 void init_glue(void);
+static PyObject *PyExc_NTSTATUSError;
+static PyObject *PyExc_WERRORError;
+static PyObject *PyExc_HRESULTError;
 
 static PyObject *py_generate_random_str(PyObject *self, PyObject *args)
 {
@@ -294,5 +297,22 @@ void init_glue(void)
 
        PyModule_AddObject(m, "version",
                                           PyString_FromString(SAMBA_VERSION_STRING));
+       PyExc_NTSTATUSError = PyErr_NewException(discard_const_p(char, "samba.NTSTATUSError"), PyExc_RuntimeError, NULL);
+       if (PyExc_NTSTATUSError != NULL) {
+               Py_INCREF(PyExc_NTSTATUSError);
+               PyModule_AddObject(m, "NTSTATUSError", PyExc_NTSTATUSError);
+       }
+
+       PyExc_WERRORError = PyErr_NewException(discard_const_p(char, "samba.WERRORError"), PyExc_RuntimeError, NULL);
+       if (PyExc_WERRORError != NULL) {
+               Py_INCREF(PyExc_WERRORError);
+               PyModule_AddObject(m, "WERRORError", PyExc_WERRORError);
+       }
+
+       PyExc_HRESULTError = PyErr_NewException(discard_const_p(char, "samba.HRESULTError"), PyExc_RuntimeError, NULL);
+       if (PyExc_HRESULTError != NULL) {
+               Py_INCREF(PyExc_HRESULTError);
+               PyModule_AddObject(m, "HRESULTError", PyExc_HRESULTError);
+       }
 }