diff options
author | Frank Ch. Eigler <fche@elastic.org> | 2009-10-14 17:02:47 -0400 |
---|---|---|
committer | Frank Ch. Eigler <fche@elastic.org> | 2009-10-14 17:05:40 -0400 |
commit | 739cf6877b9bd84b0aba47f5c4c205a9dd63a93d (patch) | |
tree | 4e8f02f3a1a668084ef6f6202826d85016369c22 /nsscommon.c | |
parent | 85dfc5c81e213a1fc67c8c50d0e1101659c61d6e (diff) | |
download | systemtap-steved-739cf6877b9bd84b0aba47f5c4c205a9dd63a93d.tar.gz systemtap-steved-739cf6877b9bd84b0aba47f5c4c205a9dd63a93d.tar.xz systemtap-steved-739cf6877b9bd84b0aba47f5c4c205a9dd63a93d.zip |
PR10331: improve nss error message handling
* stapsslerr.h: New file containing NSS* error number to string mappings.
Originally from mozilla NSS documentation, also seen in other GPLv2
software.
* nsscommon.c (nssError): Print error number, and text from <stapsslerr.h>.
* stap-{client,server}-connect.c (errWarn): Standardize on nssError().
* Makefile.am (nss binaries): Also link in nsscommon.c.
Diffstat (limited to 'nsscommon.c')
-rw-r--r-- | nsscommon.c | 31 |
1 files changed, 10 insertions, 21 deletions
diff --git a/nsscommon.c b/nsscommon.c index 2e9c748b..b94e3e63 100644 --- a/nsscommon.c +++ b/nsscommon.c @@ -36,6 +36,9 @@ nssError (void) /* See if PR_GetErrorText can tell us what the error is. */ errorNumber = PR_GetError (); + + fprintf(stderr, "(%d) ", errorNumber); + if (errorNumber >= PR_NSPR_ERROR_BASE && errorNumber <= PR_MAX_ERROR) { errorTextLength = PR_GetErrorTextLength (); @@ -50,28 +53,14 @@ nssError (void) } } - /* Otherwise handle common errors ourselves. */ - switch (errorNumber) - { - case PR_CONNECT_RESET_ERROR: - fputs ("Connection reset by peer.\n", stderr); - break; - case SEC_ERROR_BAD_DATABASE: - fputs ("The specified certificate database does not exist or is not valid.\n", stderr); - break; - case SEC_ERROR_BAD_SIGNATURE: - fputs ("Certificate does not match the signature.\n", stderr); - break; - case SEC_ERROR_CA_CERT_INVALID: - fputs ("The issuer's certificate is invalid.\n", stderr); - break; - case SSL_ERROR_BAD_CERT_DOMAIN: - fputs ("The requested domain name does not match the server's certificate.\n", stderr); - break; - default: - fprintf (stderr, "Unknown NSS error: %d.\n", errorNumber); - break; + switch (errorNumber) { + default: errorText = "(unknown)"; break; +#define NSSYERROR(code,msg) case code: errorText = msg; break +#include "stapsslerr.h" +#undef NSSYERROR } + + fprintf (stderr, "%s\n", errorText); } void |