2 * err.c : implementation of fs-private error functions
4 * ====================================================================
5 * Licensed to the Apache Software Foundation (ASF) under one
6 * or more contributor license agreements. See the NOTICE file
7 * distributed with this work for additional information
8 * regarding copyright ownership. The ASF licenses this file
9 * to you under the Apache License, Version 2.0 (the
10 * "License"); you may not use this file except in compliance
11 * with the License. You may obtain a copy of the License at
13 * http://www.apache.org/licenses/LICENSE-2.0
15 * Unless required by applicable law or agreed to in writing,
16 * software distributed under the License is distributed on an
17 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
18 * KIND, either express or implied. See the License for the
19 * specific language governing permissions and limitations
21 * ====================================================================
29 #include <apr_strings.h>
34 #include "../../libsvn_fs/fs-loader.h"
38 #include "svn_private_config.h"
41 /* Return a distinguished error for any db error code we want to detect
42 * programatically; otherwise return a generic error.
45 bdb_err_to_apr_err(int db_err)
47 if (db_err == DB_LOCK_DEADLOCK)
48 return SVN_ERR_FS_BERKELEY_DB_DEADLOCK;
50 return SVN_ERR_FS_BERKELEY_DB;
55 svn_fs_bdb__dberr(bdb_env_baton_t *bdb_baton, int db_err)
57 svn_error_t *child_errors;
59 child_errors = bdb_baton->error_info->pending_errors;
60 bdb_baton->error_info->pending_errors = NULL;
62 return svn_error_create(bdb_err_to_apr_err(db_err), child_errors,
68 svn_fs_bdb__dberrf(bdb_env_baton_t *bdb_baton,
69 int db_err, const char *fmt, ...)
74 svn_error_t *child_errors;
76 child_errors = bdb_baton->error_info->pending_errors;
77 bdb_baton->error_info->pending_errors = NULL;
79 err = svn_error_create(bdb_err_to_apr_err(db_err), child_errors, NULL);
82 msg = apr_pvsprintf(err->pool, fmt, ap);
84 err->message = apr_psprintf(err->pool, "%s%s", msg, db_strerror(db_err));
85 return svn_error_trace(err);
90 svn_fs_bdb__wrap_db(svn_fs_t *fs, const char *operation, int db_err)
92 base_fs_data_t *bfd = fs->fsap_data;
96 svn_error_clear(bfd->bdb->error_info->pending_errors);
97 bfd->bdb->error_info->pending_errors = NULL;
102 return svn_fs_bdb__dberrf
104 _("Berkeley DB error for filesystem '%s' while %s:\n"),
105 fs->path ? fs->path : "(none)", _(operation));