summaryrefslogtreecommitdiff
path: root/source4/libcli
diff options
context:
space:
mode:
authorAndrew Bartlett <abartlet@samba.org>2016-11-01 15:23:58 +1300
committerGarming Sam <garming@samba.org>2016-11-04 04:41:19 +0100
commitc8505c53da3e21f31454f121efd5961d95349a38 (patch)
tree686acac488a701d7e839390244f85f69a0dec65e /source4/libcli
parentf72da5ba51ae8bf9f3f54bed36b4572cd1b57adb (diff)
downloadsamba-c8505c53da3e21f31454f121efd5961d95349a38.tar.gz
python: create NTSTATUSError, HRESULTError and WERRORError
The advantage of these over the previous use of just RuntimeError is that we can catch just the errors we want, without having to catch all possible RuntimeError cases and assume they decode to a tuple Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Garming Sam <garming@catalyst.net.nz> BUG: https://bugzilla.samba.org/show_bug.cgi?id=12398
Diffstat (limited to 'source4/libcli')
-rw-r--r--source4/libcli/util/pyerrors.h15
1 files changed, 12 insertions, 3 deletions
diff --git a/source4/libcli/util/pyerrors.h b/source4/libcli/util/pyerrors.h
index ef997131fff..9228c340ea7 100644
--- a/source4/libcli/util/pyerrors.h
+++ b/source4/libcli/util/pyerrors.h
@@ -28,11 +28,20 @@
#define PyErr_FromString(str) Py_BuildValue("(s)", discard_const_p(char, str))
-#define PyErr_SetWERROR(err) \
- PyErr_SetObject(PyExc_RuntimeError, PyErr_FromWERROR(err))
+#define PyErr_SetWERROR(werr) \
+ PyErr_SetObject(PyObject_GetAttrString(PyImport_ImportModule("samba"),\
+ "WERRORError"), \
+ PyErr_FromWERROR(werr))
+
+#define PyErr_SetHRESULT(hresult) \
+ PyErr_SetObject(PyObject_GetAttrString(PyImport_ImportModule("samba"),\
+ "HRESULTError"), \
+ PyErr_FromHRESULT(hresult))
#define PyErr_SetNTSTATUS(status) \
- PyErr_SetObject(PyExc_RuntimeError, PyErr_FromNTSTATUS(status))
+ PyErr_SetObject(PyObject_GetAttrString(PyImport_ImportModule("samba"),\
+ "NTSTATUSError"), \
+ PyErr_FromNTSTATUS(status))
#define PyErr_NTSTATUS_IS_ERR_RAISE(status) \
if (NT_STATUS_IS_ERR(status)) { \