s4-lsa: fixed breakage of lsa server
[Samba/cd1.git] / source4 / libcli / util / pyerrors.h
blob66823f4a41cba9a6f7637828ecddefe94a92c80c
1 /*
2 Unix SMB/CIFS implementation.
3 Samba utility functions
4 Copyright (C) Jelmer Vernooij <jelmer@samba.org> 2008
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 3 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program. If not, see <http://www.gnu.org/licenses/>.
20 #ifndef __PYERRORS_H__
21 #define __PYERRORS_H__
23 #define PyErr_FromWERROR(err) Py_BuildValue("(i,s)", W_ERROR_V(err), discard_const_p(char, win_errstr(err)))
25 #define PyErr_FromNTSTATUS(status) Py_BuildValue("(i,s)", NT_STATUS_V(status), discard_const_p(char, get_friendly_nt_error_msg(status)))
27 #define PyErr_SetWERROR(err) \
28 PyErr_SetObject(PyExc_RuntimeError, PyErr_FromWERROR(err))
30 #define PyErr_SetNTSTATUS(status) \
31 PyErr_SetObject(PyExc_RuntimeError, PyErr_FromNTSTATUS(status))
33 #define PyErr_NTSTATUS_IS_ERR_RAISE(status) \
34 if (NT_STATUS_IS_ERR(status)) { \
35 PyErr_SetNTSTATUS(status); \
36 return NULL; \
39 #define PyErr_WERROR_IS_ERR_RAISE(status) \
40 if (!W_ERROR_IS_OK(status)) { \
41 PyErr_SetWERROR(status); \
42 return NULL; \
45 #endif /* __PYERRORS_H__ */