2008-05-24 21:38:33 +02:00
/*
Unix SMB / CIFS implementation .
Samba utility functions
Copyright ( C ) Jelmer Vernooij < jelmer @ samba . org > 2008
This program is free software ; you can redistribute it and / or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation ; either version 3 of the License , or
( at your option ) any later version .
This program is distributed in the hope that it will be useful ,
but WITHOUT ANY WARRANTY ; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
GNU General Public License for more details .
You should have received a copy of the GNU General Public License
along with this program . If not , see < http : //www.gnu.org/licenses/>.
*/
# ifndef __PYERRORS_H__
# define __PYERRORS_H__
2008-05-24 22:13:32 +02:00
# define PyErr_FromWERROR(err) Py_BuildValue("(i,s)", W_ERROR_V(err), discard_const_p(char, win_errstr(err)))
2008-06-17 14:21:02 +02:00
# define PyErr_FromNTSTATUS(status) Py_BuildValue("(i,s)", NT_STATUS_V(status), discard_const_p(char, get_friendly_nt_error_msg(status)))
2008-05-24 22:13:32 +02:00
2010-02-25 16:16:33 +11:00
# define PyErr_FromString(str) Py_BuildValue("(s)", discard_const_p(char, str))
2008-05-24 21:38:33 +02:00
# define PyErr_SetWERROR(err) \
2008-05-24 22:13:32 +02:00
PyErr_SetObject ( PyExc_RuntimeError , PyErr_FromWERROR ( err ) )
2008-05-24 21:38:33 +02:00
# define PyErr_SetNTSTATUS(status) \
2008-05-24 22:13:32 +02:00
PyErr_SetObject ( PyExc_RuntimeError , PyErr_FromNTSTATUS ( status ) )
2008-05-24 21:38:33 +02:00
2008-12-18 15:32:58 +00:00
# define PyErr_NTSTATUS_IS_ERR_RAISE(status) \
if ( NT_STATUS_IS_ERR ( status ) ) { \
PyErr_SetNTSTATUS ( status ) ; \
return NULL ; \
}
# define PyErr_WERROR_IS_ERR_RAISE(status) \
if ( ! W_ERROR_IS_OK ( status ) ) { \
PyErr_SetWERROR ( status ) ; \
return NULL ; \
}
2008-05-24 21:38:33 +02:00
# endif /* __PYERRORS_H__ */