From f042c1509032ff7c2ce87ea543e2fcda59b70532 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Tue, 4 Mar 2008 13:45:31 +1100 Subject: Try to return sane ldb error strings We don't just want to return just strerror(ret) when things go wrong. Andrew Bartlett (This used to be commit 7f0341dd589150ab01563957460cdcf42515cadc) --- source4/lib/ldb/ldb.i | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'source4/lib/ldb') diff --git a/source4/lib/ldb/ldb.i b/source4/lib/ldb/ldb.i index da4c52f778..0d9679d21e 100644 --- a/source4/lib/ldb/ldb.i +++ b/source4/lib/ldb/ldb.i @@ -42,6 +42,7 @@ typedef struct ldb_dn ldb_dn; typedef struct ldb_ldif ldb_ldif; typedef struct ldb_message_element ldb_msg_element; typedef int ldb_error; +typedef int ldb_int_error; %} @@ -520,6 +521,14 @@ PyObject *PyExc_LdbError; %typemap(out,noblock=1) ldb_error { + if ($1 != LDB_SUCCESS) { + PyErr_SetObject(PyExc_LdbError, Py_BuildValue((char *)"(i,s)", $1, ldb_errstring(arg1))); + SWIG_fail; + } + $result = Py_None; +}; + +%typemap(out,noblock=1) ldb_int_error { if ($1 != LDB_SUCCESS) { PyErr_SetObject(PyExc_LdbError, Py_BuildValue((char *)"(i,s)", $1, ldb_strerror($1))); SWIG_fail; @@ -761,4 +770,4 @@ time_t ldb_string_to_time(const char *s); } %rename(register_module) ldb_register_module; -ldb_error ldb_register_module(const struct ldb_module_ops *); +ldb_int_error ldb_register_module(const struct ldb_module_ops *); -- cgit