Add convenience macro for raising exceptions for NTSTATUS / WERROR.
authorJelmer Vernooij <jelmer@samba.org>
Thu, 18 Dec 2008 15:32:58 +0000 (15:32 +0000)
committerJelmer Vernooij <jelmer@samba.org>
Thu, 18 Dec 2008 15:32:58 +0000 (15:32 +0000)
source4/libcli/util/pyerrors.h

index 47e6f58b5db781d81f17f207671d229052e577d0..66823f4a41cba9a6f7637828ecddefe94a92c80c 100644 (file)
 #define PyErr_SetNTSTATUS(status) \
         PyErr_SetObject(PyExc_RuntimeError, PyErr_FromNTSTATUS(status))
 
+#define PyErr_NTSTATUS_IS_ERR_RAISE(status) \
+       if (NT_STATUS_IS_ERR(status)) { \
+               PyErr_SetNTSTATUS(status); \
+               return NULL; \
+       }
+
+#define PyErr_WERROR_IS_ERR_RAISE(status) \
+       if (!W_ERROR_IS_OK(status)) { \
+               PyErr_SetWERROR(status); \
+               return NULL; \
+       }
+
 #endif /* __PYERRORS_H__ */