source: branches/samba-3.5.x/source4/libcli/util/pyerrors.h

Last change on this file was 414, checked in by Herwig Bauernfeind, 15 years ago

Samba 3.5.0: Initial import

File size: 1.5 KB
Line 
1/*
2 Unix SMB/CIFS implementation.
3 Samba utility functions
4 Copyright (C) Jelmer Vernooij <jelmer@samba.org> 2008
5
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.
10
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.
15
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/>.
18*/
19
20#ifndef __PYERRORS_H__
21#define __PYERRORS_H__
22
23#define PyErr_FromWERROR(err) Py_BuildValue("(i,s)", W_ERROR_V(err), discard_const_p(char, win_errstr(err)))
24
25#define PyErr_FromNTSTATUS(status) Py_BuildValue("(i,s)", NT_STATUS_V(status), discard_const_p(char, get_friendly_nt_error_msg(status)))
26
27#define PyErr_SetWERROR(err) \
28 PyErr_SetObject(PyExc_RuntimeError, PyErr_FromWERROR(err))
29
30#define PyErr_SetNTSTATUS(status) \
31 PyErr_SetObject(PyExc_RuntimeError, PyErr_FromNTSTATUS(status))
32
33#define PyErr_NTSTATUS_IS_ERR_RAISE(status) \
34 if (NT_STATUS_IS_ERR(status)) { \
35 PyErr_SetNTSTATUS(status); \
36 return NULL; \
37 }
38
39#define PyErr_WERROR_IS_ERR_RAISE(status) \
40 if (!W_ERROR_IS_OK(status)) { \
41 PyErr_SetWERROR(status); \
42 return NULL; \
43 }
44
45#endif /* __PYERRORS_H__ */
Note: See TracBrowser for help on using the repository browser.