diff options
author | Andrew Bartlett <abartlet@samba.org> | 2016-11-01 16:03:09 +1300 |
---|---|---|
committer | Garming Sam <garming@samba.org> | 2016-11-04 04:41:19 +0100 |
commit | e737171f6ef172de559b41d54989eca0d7663b4e (patch) | |
tree | 0ab1f39766ea91bc83e4d98724a602e9a932bae4 /source4/libcli | |
parent | c8505c53da3e21f31454f121efd5961d95349a38 (diff) | |
download | samba-e737171f6ef172de559b41d54989eca0d7663b4e.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
Diffstat (limited to 'source4/libcli')
-rw-r--r-- | source4/libcli/util/pyerrors.h | 15 |
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); \ |