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 * ====================================================================
27 #include <apr_strings.h>
32 #include "../../libsvn_fs/fs-loader.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.
42 bdb_err_to_apr_err(int db_err
)
44 if (db_err
== DB_LOCK_DEADLOCK
)
45 return SVN_ERR_FS_BERKELEY_DB_DEADLOCK
;
47 return SVN_ERR_FS_BERKELEY_DB
;
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
,
65 svn_fs_bdb__dberrf(bdb_env_baton_t
*bdb_baton
,
66 int db_err
, const char *fmt
, ...)
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
);
79 msg
= apr_pvsprintf(err
->pool
, fmt
, ap
);
81 err
->message
= apr_psprintf(err
->pool
, "%s%s", msg
, db_strerror(db_err
));
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
;
93 svn_error_clear(bfd
->bdb
->error_info
->pending_errors
);
94 bfd
->bdb
->error_info
->pending_errors
= NULL
;
99 return svn_fs_bdb__dberrf
101 _("Berkeley DB error for filesystem '%s' while %s:\n"),
102 fs
->path
? fs
->path
: "(none)", operation
);