print.c: provide more detailed error messages if retrieving a package fails
fetch_maperror() translates error codes returned by libfetch to our error codes. Handle those in apk_error_str(), returning error messages which advise the user of the most likely fix. A custom error code, EAPKSTALEINDEX, has been added for cases where retrieving a package fails due to a HTTP error 404 or similar. [TimoT: add also EAPKBADURL, as well as organize a bit better where the EAPKSTALEINDEX is generated]cute-signatures
parent
be31eb24d8
commit
74dc8e232f
|
@ -32,6 +32,8 @@
|
||||||
#define NULL 0L
|
#define NULL 0L
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#define EAPKSTALEINDEX 1024
|
||||||
|
|
||||||
static inline void *ERR_PTR(long error) { return (void*) error; }
|
static inline void *ERR_PTR(long error) { return (void*) error; }
|
||||||
static inline void *ERR_CAST(const void *ptr) { return (void*) ptr; }
|
static inline void *ERR_CAST(const void *ptr) { return (void*) ptr; }
|
||||||
static inline int PTR_ERR(const void *ptr) { return (int)(long) ptr; }
|
static inline int PTR_ERR(const void *ptr) { return (int)(long) ptr; }
|
||||||
|
|
20
src/print.c
20
src/print.c
|
@ -133,7 +133,25 @@ const char *apk_error_str(int error)
|
||||||
case ENOMSG:
|
case ENOMSG:
|
||||||
return "archive does not contain expected data";
|
return "archive does not contain expected data";
|
||||||
case ENOPKG:
|
case ENOPKG:
|
||||||
return "package not available";
|
return "could not find a repo which provides this package (check repositories file and run 'apk update')";
|
||||||
|
case ECONNABORTED:
|
||||||
|
return "network connection aborted";
|
||||||
|
case ECONNREFUSED:
|
||||||
|
return "could not connect to server (check repositories file)";
|
||||||
|
case ENETUNREACH:
|
||||||
|
return "network error (check Internet connection and firewall)";
|
||||||
|
case ENXIO:
|
||||||
|
return "DNS lookup error";
|
||||||
|
case EREMOTEIO:
|
||||||
|
return "error code returned by repo server (try 'apk update')";
|
||||||
|
case ETIMEDOUT:
|
||||||
|
return "operation timed out";
|
||||||
|
case EAGAIN:
|
||||||
|
return "temporary error (try again later)";
|
||||||
|
case EINVAL:
|
||||||
|
return "invalid URL (check your repositories file)";
|
||||||
|
case EAPKSTALEINDEX:
|
||||||
|
return "file not available from repo server (try 'apk update')";
|
||||||
default:
|
default:
|
||||||
return strerror(error);
|
return strerror(error);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue