Rename pmhandle_t to alpm_handle_t
[pacman-ng.git] / lib / libalpm / error.c
blobfb0493ff9fb32d2b68461f395ddd8fb1de211359
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 #ifdef HAVE_LIBCURL
24 #include <curl/curl.h>
25 #endif
27 /* libalpm */
28 #include "util.h"
29 #include "alpm.h"
30 #include "handle.h"
32 enum _pmerrno_t SYMEXPORT alpm_errno(alpm_handle_t *handle)
34 return handle->pm_errno;
37 const char SYMEXPORT *alpm_strerror(enum _pmerrno_t err)
39 switch(err) {
40 /* System */
41 case PM_ERR_MEMORY:
42 return _("out of memory!");
43 case PM_ERR_SYSTEM:
44 return _("unexpected system error");
45 case PM_ERR_BADPERMS:
46 return _("insufficient privileges");
47 case PM_ERR_NOT_A_FILE:
48 return _("could not find or read file");
49 case PM_ERR_NOT_A_DIR:
50 return _("could not find or read directory");
51 case PM_ERR_WRONG_ARGS:
52 return _("wrong or NULL argument passed");
53 case PM_ERR_DISK_SPACE:
54 return _("not enough free disk space");
55 /* Interface */
56 case PM_ERR_HANDLE_NULL:
57 return _("library not initialized");
58 case PM_ERR_HANDLE_NOT_NULL:
59 return _("library already initialized");
60 case PM_ERR_HANDLE_LOCK:
61 return _("unable to lock database");
62 /* Databases */
63 case PM_ERR_DB_OPEN:
64 return _("could not open database");
65 case PM_ERR_DB_CREATE:
66 return _("could not create database");
67 case PM_ERR_DB_NULL:
68 return _("database not initialized");
69 case PM_ERR_DB_NOT_NULL:
70 return _("database already registered");
71 case PM_ERR_DB_NOT_FOUND:
72 return _("could not find database");
73 case PM_ERR_DB_INVALID:
74 return _("invalid or corrupted database");
75 case PM_ERR_DB_VERSION:
76 return _("database is incorrect version");
77 case PM_ERR_DB_WRITE:
78 return _("could not update database");
79 case PM_ERR_DB_REMOVE:
80 return _("could not remove database entry");
81 /* Servers */
82 case PM_ERR_SERVER_BAD_URL:
83 return _("invalid url for server");
84 case PM_ERR_SERVER_NONE:
85 return _("no servers configured for repository");
86 /* Transactions */
87 case PM_ERR_TRANS_NOT_NULL:
88 return _("transaction already initialized");
89 case PM_ERR_TRANS_NULL:
90 return _("transaction not initialized");
91 case PM_ERR_TRANS_DUP_TARGET:
92 return _("duplicate target");
93 case PM_ERR_TRANS_NOT_INITIALIZED:
94 return _("transaction not initialized");
95 case PM_ERR_TRANS_NOT_PREPARED:
96 return _("transaction not prepared");
97 case PM_ERR_TRANS_ABORT:
98 return _("transaction aborted");
99 case PM_ERR_TRANS_TYPE:
100 return _("operation not compatible with the transaction type");
101 case PM_ERR_TRANS_NOT_LOCKED:
102 return _("transaction commit attempt when database is not locked");
103 /* Packages */
104 case PM_ERR_PKG_NOT_FOUND:
105 return _("could not find or read package");
106 case PM_ERR_PKG_IGNORED:
107 return _("operation cancelled due to ignorepkg");
108 case PM_ERR_PKG_INVALID:
109 return _("invalid or corrupted package");
110 case PM_ERR_PKG_OPEN:
111 return _("cannot open package file");
112 case PM_ERR_PKG_CANT_REMOVE:
113 return _("cannot remove all files for package");
114 case PM_ERR_PKG_INVALID_NAME:
115 return _("package filename is not valid");
116 case PM_ERR_PKG_INVALID_ARCH:
117 return _("package architecture is not valid");
118 case PM_ERR_PKG_REPO_NOT_FOUND:
119 return _("could not find repository for target");
120 /* Signatures */
121 case PM_ERR_SIG_MISSINGDIR:
122 return _("signature directory not configured correctly");
123 case PM_ERR_SIG_INVALID:
124 return _("invalid PGP signature");
125 case PM_ERR_SIG_UNKNOWN:
126 return _("unknown PGP signature");
127 /* Deltas */
128 case PM_ERR_DLT_INVALID:
129 return _("invalid or corrupted delta");
130 case PM_ERR_DLT_PATCHFAILED:
131 return _("delta patch failed");
132 /* Dependencies */
133 case PM_ERR_UNSATISFIED_DEPS:
134 return _("could not satisfy dependencies");
135 case PM_ERR_CONFLICTING_DEPS:
136 return _("conflicting dependencies");
137 case PM_ERR_FILE_CONFLICTS:
138 return _("conflicting files");
139 /* Miscellaenous */
140 case PM_ERR_RETRIEVE:
141 return _("failed to retrieve some files");
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_LIBCURL:
151 return _("download library error");
152 case PM_ERR_GPGME:
153 return _("gpgme error");
154 case PM_ERR_EXTERNAL_DOWNLOAD:
155 return _("error invoking external downloader");
156 /* Unknown error! */
157 default:
158 return _("unexpected error");
162 /* vim: set ts=2 sw=2 noet: */