Check local DB version before continuing transaction
[pacman-ng.git] / lib / libalpm / error.c
blob21fbb48f252145715b019859a00d41191ce0bd94
1 /*
2 * error.c
4 * Copyright (c) 2006-2011 Pacman Development Team <pacman-dev@archlinux.org>
5 * Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
21 #include "config.h"
23 /* TODO: needed for the libfetch stuff, unfortunately- we should kill it */
24 #include <stdio.h>
25 /* the following two are needed for FreeBSD's libfetch */
26 #include <limits.h> /* PATH_MAX */
27 #if defined(HAVE_SYS_PARAM_H)
28 #include <sys/param.h> /* MAXHOSTNAMELEN */
29 #endif
31 #ifdef HAVE_LIBFETCH
32 #include <fetch.h> /* fetchLastErrString */
33 #endif
35 /* libalpm */
36 #include "util.h"
37 #include "alpm.h"
39 const char SYMEXPORT *alpm_strerrorlast(void)
41 return alpm_strerror(pm_errno);
44 const char SYMEXPORT *alpm_strerror(int err)
46 switch(err) {
47 /* System */
48 case PM_ERR_MEMORY:
49 return _("out of memory!");
50 case PM_ERR_SYSTEM:
51 return _("unexpected system error");
52 case PM_ERR_BADPERMS:
53 return _("insufficient privileges");
54 case PM_ERR_NOT_A_FILE:
55 return _("could not find or read file");
56 case PM_ERR_NOT_A_DIR:
57 return _("could not find or read directory");
58 case PM_ERR_WRONG_ARGS:
59 return _("wrong or NULL argument passed");
60 case PM_ERR_DISK_SPACE:
61 return _("not enough free disk space");
62 /* Interface */
63 case PM_ERR_HANDLE_NULL:
64 return _("library not initialized");
65 case PM_ERR_HANDLE_NOT_NULL:
66 return _("library already initialized");
67 case PM_ERR_HANDLE_LOCK:
68 return _("unable to lock database");
69 /* Databases */
70 case PM_ERR_DB_OPEN:
71 return _("could not open database");
72 case PM_ERR_DB_CREATE:
73 return _("could not create database");
74 case PM_ERR_DB_NULL:
75 return _("database not initialized");
76 case PM_ERR_DB_NOT_NULL:
77 return _("database already registered");
78 case PM_ERR_DB_NOT_FOUND:
79 return _("could not find database");
80 case PM_ERR_DB_VERSION:
81 return _("database is incorrect version");
82 case PM_ERR_DB_WRITE:
83 return _("could not update database");
84 case PM_ERR_DB_REMOVE:
85 return _("could not remove database entry");
86 /* Servers */
87 case PM_ERR_SERVER_BAD_URL:
88 return _("invalid url for server");
89 case PM_ERR_SERVER_NONE:
90 return _("no servers configured for repository");
91 /* Transactions */
92 case PM_ERR_TRANS_NOT_NULL:
93 return _("transaction already initialized");
94 case PM_ERR_TRANS_NULL:
95 return _("transaction not initialized");
96 case PM_ERR_TRANS_DUP_TARGET:
97 return _("duplicate target");
98 case PM_ERR_TRANS_NOT_INITIALIZED:
99 return _("transaction not initialized");
100 case PM_ERR_TRANS_NOT_PREPARED:
101 return _("transaction not prepared");
102 case PM_ERR_TRANS_ABORT:
103 return _("transaction aborted");
104 case PM_ERR_TRANS_TYPE:
105 return _("operation not compatible with the transaction type");
106 case PM_ERR_TRANS_NOT_LOCKED:
107 return _("transaction commit attempt when database is not locked");
108 /* Packages */
109 case PM_ERR_PKG_NOT_FOUND:
110 return _("could not find or read package");
111 case PM_ERR_PKG_IGNORED:
112 return _("operation cancelled due to ignorepkg");
113 case PM_ERR_PKG_INVALID:
114 return _("invalid or corrupted package");
115 case PM_ERR_PKG_OPEN:
116 return _("cannot open package file");
117 case PM_ERR_PKG_CANT_REMOVE:
118 return _("cannot remove all files for package");
119 case PM_ERR_PKG_INVALID_NAME:
120 return _("package filename is not valid");
121 case PM_ERR_PKG_INVALID_ARCH:
122 return _("package architecture is not valid");
123 case PM_ERR_PKG_REPO_NOT_FOUND:
124 return _("could not find repository for target");
125 /* Deltas */
126 case PM_ERR_DLT_INVALID:
127 return _("invalid or corrupted delta");
128 case PM_ERR_DLT_PATCHFAILED:
129 return _("delta patch failed");
130 /* Dependencies */
131 case PM_ERR_UNSATISFIED_DEPS:
132 return _("could not satisfy dependencies");
133 case PM_ERR_CONFLICTING_DEPS:
134 return _("conflicting dependencies");
135 case PM_ERR_FILE_CONFLICTS:
136 return _("conflicting files");
137 /* Miscellaenous */
138 case PM_ERR_RETRIEVE:
139 return _("failed to retrieve some files");
140 case PM_ERR_WRITE:
141 return _("failed to copy some file");
142 case PM_ERR_INVALID_REGEX:
143 return _("invalid regular expression");
144 /* Errors from external libraries- our own wrapper error */
145 case PM_ERR_LIBARCHIVE:
146 /* it would be nice to use archive_error_string() here, but that
147 * requires the archive struct, so we can't. Just use a generic
148 * error string instead. */
149 return _("libarchive error");
150 case PM_ERR_LIBFETCH:
151 #ifdef HAVE_LIBFETCH
152 return fetchLastErrString;
153 #else
154 /* obviously shouldn't get here... */
155 return _("download library error");
156 #endif
157 case PM_ERR_EXTERNAL_DOWNLOAD:
158 return _("error invoking external downloader");
159 /* Unknown error! */
160 default:
161 return _("unexpected error");
165 /* vim: set ts=2 sw=2 noet: */