summaryrefslogtreecommitdiff
path: root/source4/lib/ldb/common
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2010-07-06 13:20:19 +1000
committerAndrew Tridgell <tridge@samba.org>2010-07-07 20:14:55 +1000
commitfc68558ab937859a91214e8675d53c0afaf3c4e6 (patch)
treed24b0d33ffe497012382fb773dea49234e757d2a /source4/lib/ldb/common
parent0b6cebd60288b37f28176e24abeb20109dfd70e5 (diff)
downloadsamba-fc68558ab937859a91214e8675d53c0afaf3c4e6.tar.gz
samba-fc68558ab937859a91214e8675d53c0afaf3c4e6.tar.bz2
samba-fc68558ab937859a91214e8675d53c0afaf3c4e6.zip
s4-ldb: added ldb_error() and ldb_operr()
These will be used to help avoid the problem we have with hundreds of places that do "return LDB_ERR_OPERATIONS_ERROR" without an explanation. It is very difficult to track down ldb errors which don't have any explanation. By replacing "return LDB_ERR_OPERATIONS_ERROR;" with "return ldb_operr(ldb);" we at least get a file:line message in the ldb error string. It isn't an ideal error message, but it is much better than just "operations error" This change also makes ldb_oom() return the error code (LDB_ERR_OPERATIONS_ERROR) so you can do: return ldb_oom(ldb); instead of: ldb_oom(ldb); return LDB_ERR_OPERATIONS_ERROR;
Diffstat (limited to 'source4/lib/ldb/common')
-rw-r--r--source4/lib/ldb/common/ldb.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/source4/lib/ldb/common/ldb.c b/source4/lib/ldb/common/ldb.c
index 07aa6d0985..877f283491 100644
--- a/source4/lib/ldb/common/ldb.c
+++ b/source4/lib/ldb/common/ldb.c
@@ -285,6 +285,22 @@ void ldb_reset_err_string(struct ldb_context *ldb)
}
}
+
+
+/*
+ set an ldb error based on file:line
+*/
+int ldb_error_at(struct ldb_context *ldb, int ecode,
+ const char *reason, const char *file, int line)
+{
+ if (reason == NULL) {
+ reason = ldb_strerror(ecode);
+ }
+ ldb_asprintf_errstring(ldb, "%s at %s:%d", reason, file, line);
+ return ecode;
+}
+
+
#define FIRST_OP_NOERR(ldb, op) do { \
module = ldb->modules; \
while (module && module->ops->op == NULL) module = module->next; \