diff options
author | Allan McRae <allan@archlinux.org> | 2016-04-02 07:23:25 +0200 |
---|---|---|
committer | Allan McRae <allan@archlinux.org> | 2016-05-05 05:52:23 +0200 |
commit | 502e0d1db0f588d3067a2d464824e8f1cff20ca1 (patch) | |
tree | e46ecbd7ef053bdd15c9c36ff3c309d6d15b9fc1 | |
parent | a194fb434e030a1668f08283c8a4d71428be86b5 (diff) | |
download | pacman-502e0d1db0f588d3067a2d464824e8f1cff20ca1.tar.gz pacman-502e0d1db0f588d3067a2d464824e8f1cff20ca1.tar.xz |
pacman_query: move error messages into relevant if statements
This ensures any additions to these test do not have to rely on the correct
error condition being set by libalpm.
Signed-off-by: Allan McRae <allan@archlinux.org>
-rw-r--r-- | src/pacman/query.c | 32 |
1 files changed, 16 insertions, 16 deletions
diff --git a/src/pacman/query.c b/src/pacman/query.c index 0cc12e6c..1d102a9e 100644 --- a/src/pacman/query.c +++ b/src/pacman/query.c @@ -460,27 +460,27 @@ int pacman_query(alpm_list_t *targets) if(config->op_q_isfile) { alpm_pkg_load(config->handle, strname, 1, 0, &pkg); + + if(pkg == NULL) { + pm_printf(ALPM_LOG_ERROR, + _("could not load package '%s': %s\n"), strname, + alpm_strerror(alpm_errno(config->handle))); + } } else { pkg = alpm_db_get_pkg(db_local, strname); + + if(pkg == NULL) { + pm_printf(ALPM_LOG_ERROR, + _("package '%s' was not found\n"), strname); + if(!config->op_q_isfile && access(strname, R_OK) == 0) { + pm_printf(ALPM_LOG_WARNING, + _("'%s' is a file, you might want to use %s.\n"), + strname, "-p/--file"); + } + } } if(pkg == NULL) { - switch(alpm_errno(config->handle)) { - case ALPM_ERR_PKG_NOT_FOUND: - pm_printf(ALPM_LOG_ERROR, - _("package '%s' was not found\n"), strname); - if(!config->op_q_isfile && access(strname, R_OK) == 0) { - pm_printf(ALPM_LOG_WARNING, - _("'%s' is a file, you might want to use %s.\n"), - strname, "-p/--file"); - } - break; - default: - pm_printf(ALPM_LOG_ERROR, - _("could not load package '%s': %s\n"), strname, - alpm_strerror(alpm_errno(config->handle))); - break; - } ret = 1; continue; } |