Clean up libfetch checking in configure
[pacman-ng.git] / lib / libalpm / error.c
blobb64ee67c2640ddd10aaabfbf61648bfc39d55452
1 /*
2 * error.c
4 * Copyright (c) 2006-2010 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 #include <limits.h>
26 /* the following two are needed on BSD for libfetch */
27 #if defined(HAVE_SYS_SYSLIMITS_H)
28 #include <sys/syslimits.h> /* PATH_MAX */
29 #endif
30 #if defined(HAVE_SYS_PARAM_H)
31 #include <sys/param.h> /* MAXHOSTNAMELEN */
32 #endif
34 #ifdef HAVE_FETCH
35 #include <fetch.h> /* fetchLastErrString */
36 #endif
38 /* libalpm */
39 #include "util.h"
40 #include "alpm.h"
42 const char SYMEXPORT *alpm_strerrorlast(void)
44 return alpm_strerror(pm_errno);
47 const char SYMEXPORT *alpm_strerror(int err)
49 switch(err) {
50 /* System */
51 case PM_ERR_MEMORY:
52 return _("out of memory!");
53 case PM_ERR_SYSTEM:
54 return _("unexpected system error");
55 case PM_ERR_BADPERMS:
56 return _("insufficient privileges");
57 case PM_ERR_NOT_A_FILE:
58 return _("could not find or read file");
59 case PM_ERR_NOT_A_DIR:
60 return _("could not find or read directory");
61 case PM_ERR_WRONG_ARGS:
62 return _("wrong or NULL argument passed");
63 /* Interface */
64 case PM_ERR_HANDLE_NULL:
65 return _("library not initialized");
66 case PM_ERR_HANDLE_NOT_NULL:
67 return _("library already initialized");
68 case PM_ERR_HANDLE_LOCK:
69 return _("unable to lock database");
70 /* Databases */
71 case PM_ERR_DB_OPEN:
72 return _("could not open database");
73 case PM_ERR_DB_CREATE:
74 return _("could not create database");
75 case PM_ERR_DB_NULL:
76 return _("database not initialized");
77 case PM_ERR_DB_NOT_NULL:
78 return _("database already registered");
79 case PM_ERR_DB_NOT_FOUND:
80 return _("could not find database");
81 case PM_ERR_DB_WRITE:
82 return _("could not update database");
83 case PM_ERR_DB_REMOVE:
84 return _("could not remove database entry");
85 /* Servers */
86 case PM_ERR_SERVER_BAD_URL:
87 return _("invalid url for server");
88 case PM_ERR_SERVER_NONE:
89 return _("no servers configured for repository");
90 /* Transactions */
91 case PM_ERR_TRANS_NOT_NULL:
92 return _("transaction already initialized");
93 case PM_ERR_TRANS_NULL:
94 return _("transaction not initialized");
95 case PM_ERR_TRANS_DUP_TARGET:
96 return _("duplicate target");
97 case PM_ERR_TRANS_NOT_INITIALIZED:
98 return _("transaction not initialized");
99 case PM_ERR_TRANS_NOT_PREPARED:
100 return _("transaction not prepared");
101 case PM_ERR_TRANS_ABORT:
102 return _("transaction aborted");
103 case PM_ERR_TRANS_TYPE:
104 return _("operation not compatible with the transaction type");
105 case PM_ERR_TRANS_NOT_LOCKED:
106 return _("transaction commit attempt when database is not locked");
107 /* Packages */
108 case PM_ERR_PKG_NOT_FOUND:
109 return _("could not find or read package");
110 case PM_ERR_PKG_IGNORED:
111 return _("operation cancelled due to ignorepkg");
112 case PM_ERR_PKG_INVALID:
113 return _("invalid or corrupted package");
114 case PM_ERR_PKG_OPEN:
115 return _("cannot open package file");
116 case PM_ERR_PKG_CANT_REMOVE:
117 return _("cannot remove all files for package");
118 case PM_ERR_PKG_INVALID_NAME:
119 return _("package filename is not valid");
120 case PM_ERR_PKG_INVALID_ARCH:
121 return _("package architecture is not valid");
122 case PM_ERR_PKG_REPO_NOT_FOUND:
123 return _("could not find repository for target");
124 /* Deltas */
125 case PM_ERR_DLT_INVALID:
126 return _("invalid or corrupted delta");
127 case PM_ERR_DLT_PATCHFAILED:
128 return _("delta patch failed");
129 /* Dependencies */
130 case PM_ERR_UNSATISFIED_DEPS:
131 return _("could not satisfy dependencies");
132 case PM_ERR_CONFLICTING_DEPS:
133 return _("conflicting dependencies");
134 case PM_ERR_FILE_CONFLICTS:
135 return _("conflicting files");
136 /* Miscellaenous */
137 case PM_ERR_RETRIEVE:
138 return _("failed to retrieve some files");
139 case PM_ERR_INVALID_REGEX:
140 return _("invalid regular expression");
141 /* Errors from external libraries- our own wrapper error */
142 case PM_ERR_LIBARCHIVE:
143 /* it would be nice to use archive_error_string() here, but that
144 * requires the archive struct, so we can't. Just use a generic
145 * error string instead. */
146 return _("libarchive error");
147 case PM_ERR_LIBFETCH:
148 #ifdef HAVE_FETCH
149 return fetchLastErrString;
150 #else
151 /* obviously shouldn't get here... */
152 return _("download library error");
153 #endif
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: */