libalpm
Arch Linux Package Manager Library
error.c
Go to the documentation of this file.
00001 /*
00002  *  error.c
00003  *
00004  *  Copyright (c) 2006-2011 Pacman Development Team <pacman-dev@archlinux.org>
00005  *  Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
00006  *
00007  *  This program is free software; you can redistribute it and/or modify
00008  *  it under the terms of the GNU General Public License as published by
00009  *  the Free Software Foundation; either version 2 of the License, or
00010  *  (at your option) any later version.
00011  *
00012  *  This program is distributed in the hope that it will be useful,
00013  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  *  GNU General Public License for more details.
00016  *
00017  *  You should have received a copy of the GNU General Public License
00018  *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
00019  */
00020 
00021 #ifdef HAVE_LIBCURL
00022 #include <curl/curl.h>
00023 #endif
00024 
00025 /* libalpm */
00026 #include "util.h"
00027 #include "alpm.h"
00028 #include "handle.h"
00029 
00030 alpm_errno_t SYMEXPORT alpm_errno(alpm_handle_t *handle)
00031 {
00032     return handle->pm_errno;
00033 }
00034 
00035 const char SYMEXPORT *alpm_strerror(alpm_errno_t err)
00036 {
00037     switch(err) {
00038         /* System */
00039         case ALPM_ERR_MEMORY:
00040             return _("out of memory!");
00041         case ALPM_ERR_SYSTEM:
00042             return _("unexpected system error");
00043         case ALPM_ERR_BADPERMS:
00044             return _("insufficient privileges");
00045         case ALPM_ERR_NOT_A_FILE:
00046             return _("could not find or read file");
00047         case ALPM_ERR_NOT_A_DIR:
00048             return _("could not find or read directory");
00049         case ALPM_ERR_WRONG_ARGS:
00050             return _("wrong or NULL argument passed");
00051         case ALPM_ERR_DISK_SPACE:
00052             return _("not enough free disk space");
00053         /* Interface */
00054         case ALPM_ERR_HANDLE_NULL:
00055             return _("library not initialized");
00056         case ALPM_ERR_HANDLE_NOT_NULL:
00057             return _("library already initialized");
00058         case ALPM_ERR_HANDLE_LOCK:
00059             return _("unable to lock database");
00060         /* Databases */
00061         case ALPM_ERR_DB_OPEN:
00062             return _("could not open database");
00063         case ALPM_ERR_DB_CREATE:
00064             return _("could not create database");
00065         case ALPM_ERR_DB_NULL:
00066             return _("database not initialized");
00067         case ALPM_ERR_DB_NOT_NULL:
00068             return _("database already registered");
00069         case ALPM_ERR_DB_NOT_FOUND:
00070             return _("could not find database");
00071         case ALPM_ERR_DB_INVALID:
00072             return _("invalid or corrupted database");
00073         case ALPM_ERR_DB_INVALID_SIG:
00074             return _("invalid or corrupted database (PGP signature)");
00075         case ALPM_ERR_DB_VERSION:
00076             return _("database is incorrect version");
00077         case ALPM_ERR_DB_WRITE:
00078             return _("could not update database");
00079         case ALPM_ERR_DB_REMOVE:
00080             return _("could not remove database entry");
00081         /* Servers */
00082         case ALPM_ERR_SERVER_BAD_URL:
00083             return _("invalid url for server");
00084         case ALPM_ERR_SERVER_NONE:
00085             return _("no servers configured for repository");
00086         /* Transactions */
00087         case ALPM_ERR_TRANS_NOT_NULL:
00088             return _("transaction already initialized");
00089         case ALPM_ERR_TRANS_NULL:
00090             return _("transaction not initialized");
00091         case ALPM_ERR_TRANS_DUP_TARGET:
00092             return _("duplicate target");
00093         case ALPM_ERR_TRANS_NOT_INITIALIZED:
00094             return _("transaction not initialized");
00095         case ALPM_ERR_TRANS_NOT_PREPARED:
00096             return _("transaction not prepared");
00097         case ALPM_ERR_TRANS_ABORT:
00098             return _("transaction aborted");
00099         case ALPM_ERR_TRANS_TYPE:
00100             return _("operation not compatible with the transaction type");
00101         case ALPM_ERR_TRANS_NOT_LOCKED:
00102             return _("transaction commit attempt when database is not locked");
00103         /* Packages */
00104         case ALPM_ERR_PKG_NOT_FOUND:
00105             return _("could not find or read package");
00106         case ALPM_ERR_PKG_IGNORED:
00107             return _("operation cancelled due to ignorepkg");
00108         case ALPM_ERR_PKG_INVALID:
00109             return _("invalid or corrupted package");
00110         case ALPM_ERR_PKG_INVALID_CHECKSUM:
00111             return _("invalid or corrupted package (checksum)");
00112         case ALPM_ERR_PKG_INVALID_SIG:
00113             return _("invalid or corrupted package (PGP signature)");
00114         case ALPM_ERR_PKG_OPEN:
00115             return _("cannot open package file");
00116         case ALPM_ERR_PKG_CANT_REMOVE:
00117             return _("cannot remove all files for package");
00118         case ALPM_ERR_PKG_INVALID_NAME:
00119             return _("package filename is not valid");
00120         case ALPM_ERR_PKG_INVALID_ARCH:
00121             return _("package architecture is not valid");
00122         case ALPM_ERR_PKG_REPO_NOT_FOUND:
00123             return _("could not find repository for target");
00124         /* Signatures */
00125         case ALPM_ERR_SIG_MISSING:
00126             return _("missing PGP signature");
00127         case ALPM_ERR_SIG_INVALID:
00128             return _("invalid PGP signature");
00129         /* Deltas */
00130         case ALPM_ERR_DLT_INVALID:
00131             return _("invalid or corrupted delta");
00132         case ALPM_ERR_DLT_PATCHFAILED:
00133             return _("delta patch failed");
00134         /* Dependencies */
00135         case ALPM_ERR_UNSATISFIED_DEPS:
00136             return _("could not satisfy dependencies");
00137         case ALPM_ERR_CONFLICTING_DEPS:
00138             return _("conflicting dependencies");
00139         case ALPM_ERR_FILE_CONFLICTS:
00140             return _("conflicting files");
00141         /* Miscellaenous */
00142         case ALPM_ERR_RETRIEVE:
00143             return _("failed to retrieve some files");
00144         case ALPM_ERR_INVALID_REGEX:
00145             return _("invalid regular expression");
00146         /* Errors from external libraries- our own wrapper error */
00147         case ALPM_ERR_LIBARCHIVE:
00148             /* it would be nice to use archive_error_string() here, but that
00149              * requires the archive struct, so we can't. Just use a generic
00150              * error string instead. */
00151             return _("libarchive error");
00152         case ALPM_ERR_LIBCURL:
00153             return _("download library error");
00154         case ALPM_ERR_GPGME:
00155             return _("gpgme error");
00156         case ALPM_ERR_EXTERNAL_DOWNLOAD:
00157             return _("error invoking external downloader");
00158         /* Unknown error! */
00159         default:
00160             return _("unexpected error");
00161     }
00162 }
00163 
00164 /* vim: set ts=2 sw=2 noet: */