mirror of
https://github.com/moparisthebest/pacman
synced 2024-08-13 17:03:46 -04:00
Better error handling out of package load method
There are many other ways to fail a package load other than "file not found". We should also use the correct error code in this case. Clean it up a bit in the various callers. Signed-off-by: Dan McGee <dan@archlinux.org>
This commit is contained in:
parent
dc3336c277
commit
2cfcc874b9
@ -308,7 +308,7 @@ alpm_pkg_t *_alpm_pkg_load_internal(alpm_handle_t *handle, const char *pkgfile,
|
||||
newpkg->size = st.st_size;
|
||||
} else {
|
||||
/* couldn't stat the pkgfile, return an error */
|
||||
RET_ERR(handle, ALPM_ERR_PKG_OPEN, NULL);
|
||||
RET_ERR(handle, ALPM_ERR_PKG_NOT_FOUND, NULL);
|
||||
}
|
||||
|
||||
/* can we get away with skipping checksums? */
|
||||
|
@ -332,7 +332,7 @@ static int query_group(alpm_list_t *targets)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
pm_fprintf(stderr, ALPM_LOG_ERROR, _("group \"%s\" was not found\n"), grpname);
|
||||
pm_fprintf(stderr, ALPM_LOG_ERROR, _("group '%s' was not found\n"), grpname);
|
||||
ret++;
|
||||
}
|
||||
}
|
||||
@ -560,7 +560,17 @@ int pacman_query(alpm_list_t *targets)
|
||||
}
|
||||
|
||||
if(pkg == NULL) {
|
||||
pm_fprintf(stderr, ALPM_LOG_ERROR, _("package \"%s\" not found\n"), strname);
|
||||
switch(alpm_errno(config->handle)) {
|
||||
case ALPM_ERR_PKG_NOT_FOUND:
|
||||
pm_fprintf(stderr, ALPM_LOG_ERROR,
|
||||
_("package '%s' was not found\n"), strname);
|
||||
break;
|
||||
default:
|
||||
pm_fprintf(stderr, ALPM_LOG_ERROR,
|
||||
_("could not load package '%s': %s\n"), strname,
|
||||
alpm_strerror(alpm_errno(config->handle)));
|
||||
break;
|
||||
}
|
||||
ret = 1;
|
||||
continue;
|
||||
}
|
||||
|
@ -63,6 +63,9 @@ int main(int argc, char *argv[])
|
||||
|| pkg == NULL) {
|
||||
err = alpm_errno(handle);
|
||||
switch(err) {
|
||||
case ALPM_ERR_PKG_NOT_FOUND:
|
||||
printf("Cannot find the given file.\n");
|
||||
break;
|
||||
case ALPM_ERR_PKG_OPEN:
|
||||
printf("Cannot open the given file.\n");
|
||||
break;
|
||||
|
Loading…
Reference in New Issue
Block a user