summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Bartlett <abartlet@samba.org>2016-11-01 16:03:09 +1300
committerKarolin Seeger <kseeger@samba.org>2016-11-30 12:19:34 +0100
commit31d24bfb2a6954d43d179eeccd5070e64bc871fa (patch)
tree83de88e1d7738c8e9f42dd288c9d9bf649837701
parent7396b5efdda4efa6d9705f1e304a643afa3324f9 (diff)
downloadsamba-31d24bfb2a6954d43d179eeccd5070e64bc871fa.tar.gz
pyerrors: Add PyErr_Set{WERROR,HRESULT,NTSTATUS}_and_string()
This varient allows control of the text explaination string 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 (cherry picked from commit e737171f6ef172de559b41d54989eca0d7663b4e)
-rw-r--r--source4/libcli/util/pyerrors.h15
1 files changed, 15 insertions, 0 deletions
diff --git a/source4/libcli/util/pyerrors.h b/source4/libcli/util/pyerrors.h
index 9228c340ea7..c3b307646ba 100644
--- a/source4/libcli/util/pyerrors.h
+++ b/source4/libcli/util/pyerrors.h
@@ -43,6 +43,21 @@
"NTSTATUSError"), \
PyErr_FromNTSTATUS(status))
+#define PyErr_SetWERROR_and_string(werr, string) \
+ PyErr_SetObject(PyObject_GetAttrString(PyImport_ImportModule("samba"),\
+ "WERRORError"), \
+ Py_BuildValue("(i,s)", W_ERROR_V(werr), string))
+
+#define PyErr_SetHRESULT_and_string(hresult, string) \
+ PyErr_SetObject(PyObject_GetAttrString(PyImport_ImportModule("samba"),\
+ "HRESULTError"), \
+ Py_BuildValue("(i,s)", HRES_ERROR_V(hresult), string))
+
+#define PyErr_SetNTSTATUS_and_string(status, string) \
+ PyErr_SetObject(PyObject_GetAttrString(PyImport_ImportModule("samba"),\
+ "NTSTATUSError"), \
+ Py_BuildValue("(i,s)", NT_STATUS_V(status), string))
+
#define PyErr_NTSTATUS_IS_ERR_RAISE(status) \
if (NT_STATUS_IS_ERR(status)) { \
PyErr_SetNTSTATUS(status); \