Mark many merge tests as skip-against-old-server.
[svn.git] / subversion / libsvn_fs_base / bdb / bdb-err.c
blob38f7ae4a7245b6da4c61eb5e1d8472ce104fae5f
1 /*
2 * err.c : implementation of fs-private error functions
4 * ====================================================================
5 * Copyright (c) 2000-2006 CollabNet. All rights reserved.
7 * This software is licensed as described in the file COPYING, which
8 * you should have received as part of this distribution. The terms
9 * are also available at http://subversion.tigris.org/license-1.html.
10 * If newer versions of this license are posted there, you may use a
11 * newer version instead, at your option.
13 * This software consists of voluntary contributions made by many
14 * individuals. For exact contribution history, see the revision
15 * history and logs, available at http://subversion.tigris.org/.
16 * ====================================================================
21 #include <stdlib.h>
22 #include <stdarg.h>
24 #define APU_WANT_DB
25 #include <apu_want.h>
27 #include <apr_strings.h>
29 #include "svn_fs.h"
30 #include "../fs.h"
31 #include "../err.h"
32 #include "../../libsvn_fs/fs-loader.h"
33 #include "bdb-err.h"
35 #include "svn_private_config.h"
38 /* Return a distinguished error for any db error code we want to detect
39 * programatically; otherwise return a generic error.
41 static int
42 bdb_err_to_apr_err(int db_err)
44 if (db_err == DB_LOCK_DEADLOCK)
45 return SVN_ERR_FS_BERKELEY_DB_DEADLOCK;
46 else
47 return SVN_ERR_FS_BERKELEY_DB;
51 svn_error_t *
52 svn_fs_bdb__dberr(bdb_env_baton_t *bdb_baton, int db_err)
54 svn_error_t *child_errors;
56 child_errors = bdb_baton->error_info->pending_errors;
57 bdb_baton->error_info->pending_errors = NULL;
59 return svn_error_create(bdb_err_to_apr_err(db_err), child_errors,
60 db_strerror(db_err));
64 svn_error_t *
65 svn_fs_bdb__dberrf(bdb_env_baton_t *bdb_baton,
66 int db_err, const char *fmt, ...)
68 va_list ap;
69 char *msg;
70 svn_error_t *err;
71 svn_error_t *child_errors;
73 child_errors = bdb_baton->error_info->pending_errors;
74 bdb_baton->error_info->pending_errors = NULL;
76 err = svn_error_create(bdb_err_to_apr_err(db_err), child_errors, NULL);
78 va_start(ap, fmt);
79 msg = apr_pvsprintf(err->pool, fmt, ap);
80 va_end(ap);
81 err->message = apr_psprintf(err->pool, "%s%s", msg, db_strerror(db_err));
82 return err;
86 svn_error_t *
87 svn_fs_bdb__wrap_db(svn_fs_t *fs, const char *operation, int db_err)
89 base_fs_data_t *bfd = fs->fsap_data;
91 if (! db_err)
93 svn_error_clear(bfd->bdb->error_info->pending_errors);
94 bfd->bdb->error_info->pending_errors = NULL;
95 return SVN_NO_ERROR;
98 bfd = fs->fsap_data;
99 return svn_fs_bdb__dberrf
100 (bfd->bdb, db_err,
101 _("Berkeley DB error for filesystem '%s' while %s:\n"),
102 fs->path ? fs->path : "(none)", operation);