source: trunk/server/source4/libcli/util/pyerrors.h

Last change on this file was 745, checked in by Silvan Scherrer, 13 years ago

Samba Server: updated trunk to 3.6.0

File size: 1.6 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_FromString(str) Py_BuildValue("(s)", discard_const_p(char, str))
28
29#define PyErr_SetWERROR(err) \
30 PyErr_SetObject(PyExc_RuntimeError, PyErr_FromWERROR(err))
31
32#define PyErr_SetNTSTATUS(status) \
33 PyErr_SetObject(PyExc_RuntimeError, PyErr_FromNTSTATUS(status))
34
35#define PyErr_NTSTATUS_IS_ERR_RAISE(status) \
36 if (NT_STATUS_IS_ERR(status)) { \
37 PyErr_SetNTSTATUS(status); \
38 return NULL; \
39 }
40
41#define PyErr_WERROR_IS_ERR_RAISE(status) \
42 if (!W_ERROR_IS_OK(status)) { \
43 PyErr_SetWERROR(status); \
44 return NULL; \
45 }
46
47#endif /* __PYERRORS_H__ */
Note: See TracBrowser for help on using the repository browser.