PageRenderTime 41ms CodeModel.GetById 17ms RepoModel.GetById 0ms app.codeStats 0ms

/lib/libalpm/error.c

https://github.com/mineo/pacman
C | 162 lines | 120 code | 6 blank | 36 comment | 0 complexity | b4315976d7d0a02de2375016447828f9 MD5 | raw file
Possible License(s): GPL-2.0
  1. /*
  2. * error.c
  3. *
  4. * Copyright (c) 2006-2011 Pacman Development Team <pacman-dev@archlinux.org>
  5. * Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
  6. *
  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.
  11. *
  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.
  16. *
  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/>.
  19. */
  20. #include "config.h"
  21. #ifdef HAVE_LIBCURL
  22. #include <curl/curl.h>
  23. #endif
  24. /* libalpm */
  25. #include "util.h"
  26. #include "alpm.h"
  27. #include "handle.h"
  28. enum _pmerrno_t SYMEXPORT alpm_errno(pmhandle_t *handle)
  29. {
  30. return handle->pm_errno;
  31. }
  32. const char SYMEXPORT *alpm_strerror(enum _pmerrno_t err)
  33. {
  34. switch(err) {
  35. /* System */
  36. case PM_ERR_MEMORY:
  37. return _("out of memory!");
  38. case PM_ERR_SYSTEM:
  39. return _("unexpected system error");
  40. case PM_ERR_BADPERMS:
  41. return _("insufficient privileges");
  42. case PM_ERR_NOT_A_FILE:
  43. return _("could not find or read file");
  44. case PM_ERR_NOT_A_DIR:
  45. return _("could not find or read directory");
  46. case PM_ERR_WRONG_ARGS:
  47. return _("wrong or NULL argument passed");
  48. case PM_ERR_DISK_SPACE:
  49. return _("not enough free disk space");
  50. /* Interface */
  51. case PM_ERR_HANDLE_NULL:
  52. return _("library not initialized");
  53. case PM_ERR_HANDLE_NOT_NULL:
  54. return _("library already initialized");
  55. case PM_ERR_HANDLE_LOCK:
  56. return _("unable to lock database");
  57. /* Databases */
  58. case PM_ERR_DB_OPEN:
  59. return _("could not open database");
  60. case PM_ERR_DB_CREATE:
  61. return _("could not create database");
  62. case PM_ERR_DB_NULL:
  63. return _("database not initialized");
  64. case PM_ERR_DB_NOT_NULL:
  65. return _("database already registered");
  66. case PM_ERR_DB_NOT_FOUND:
  67. return _("could not find database");
  68. case PM_ERR_DB_INVALID:
  69. return _("invalid or corrupted database");
  70. case PM_ERR_DB_VERSION:
  71. return _("database is incorrect version");
  72. case PM_ERR_DB_WRITE:
  73. return _("could not update database");
  74. case PM_ERR_DB_REMOVE:
  75. return _("could not remove database entry");
  76. /* Servers */
  77. case PM_ERR_SERVER_BAD_URL:
  78. return _("invalid url for server");
  79. case PM_ERR_SERVER_NONE:
  80. return _("no servers configured for repository");
  81. /* Transactions */
  82. case PM_ERR_TRANS_NOT_NULL:
  83. return _("transaction already initialized");
  84. case PM_ERR_TRANS_NULL:
  85. return _("transaction not initialized");
  86. case PM_ERR_TRANS_DUP_TARGET:
  87. return _("duplicate target");
  88. case PM_ERR_TRANS_NOT_INITIALIZED:
  89. return _("transaction not initialized");
  90. case PM_ERR_TRANS_NOT_PREPARED:
  91. return _("transaction not prepared");
  92. case PM_ERR_TRANS_ABORT:
  93. return _("transaction aborted");
  94. case PM_ERR_TRANS_TYPE:
  95. return _("operation not compatible with the transaction type");
  96. case PM_ERR_TRANS_NOT_LOCKED:
  97. return _("transaction commit attempt when database is not locked");
  98. /* Packages */
  99. case PM_ERR_PKG_NOT_FOUND:
  100. return _("could not find or read package");
  101. case PM_ERR_PKG_IGNORED:
  102. return _("operation cancelled due to ignorepkg");
  103. case PM_ERR_PKG_INVALID:
  104. return _("invalid or corrupted package");
  105. case PM_ERR_PKG_OPEN:
  106. return _("cannot open package file");
  107. case PM_ERR_PKG_CANT_REMOVE:
  108. return _("cannot remove all files for package");
  109. case PM_ERR_PKG_INVALID_NAME:
  110. return _("package filename is not valid");
  111. case PM_ERR_PKG_INVALID_ARCH:
  112. return _("package architecture is not valid");
  113. case PM_ERR_PKG_REPO_NOT_FOUND:
  114. return _("could not find repository for target");
  115. /* Signatures */
  116. case PM_ERR_SIG_MISSINGDIR:
  117. return _("signature directory not configured correctly");
  118. case PM_ERR_SIG_INVALID:
  119. return _("invalid PGP signature");
  120. case PM_ERR_SIG_UNKNOWN:
  121. return _("unknown PGP signature");
  122. /* Deltas */
  123. case PM_ERR_DLT_INVALID:
  124. return _("invalid or corrupted delta");
  125. case PM_ERR_DLT_PATCHFAILED:
  126. return _("delta patch failed");
  127. /* Dependencies */
  128. case PM_ERR_UNSATISFIED_DEPS:
  129. return _("could not satisfy dependencies");
  130. case PM_ERR_CONFLICTING_DEPS:
  131. return _("conflicting dependencies");
  132. case PM_ERR_FILE_CONFLICTS:
  133. return _("conflicting files");
  134. /* Miscellaenous */
  135. case PM_ERR_RETRIEVE:
  136. return _("failed to retrieve some files");
  137. case PM_ERR_INVALID_REGEX:
  138. return _("invalid regular expression");
  139. /* Errors from external libraries- our own wrapper error */
  140. case PM_ERR_LIBARCHIVE:
  141. /* it would be nice to use archive_error_string() here, but that
  142. * requires the archive struct, so we can't. Just use a generic
  143. * error string instead. */
  144. return _("libarchive error");
  145. case PM_ERR_LIBCURL:
  146. return _("download library error");
  147. case PM_ERR_GPGME:
  148. return _("gpgme error");
  149. case PM_ERR_EXTERNAL_DOWNLOAD:
  150. return _("error invoking external downloader");
  151. /* Unknown error! */
  152. default:
  153. return _("unexpected error");
  154. }
  155. }
  156. /* vim: set ts=2 sw=2 noet: */