[121] in Kerberos_V5_Development
error codes again
qjb@ATHENA.MIT.EDU (qjb@ATHENA.MIT.EDU)
Sat Jan 20 16:49:19 1990
I believe that error codes should consist of an error number and
a string (that is both grep-for-able and informative to the
user). This is not what's happening so far.
An example is if I call malloc and get an error, I want to
return KRB5_NO_MEMORY and a string that indicates where the
problem occured. I don't think that libraries should be in the
habbit of printing error messages.
The method I have used in the past with success to do this is as
follows:
Have a file containing two routines and a static text buffer.
One routine (krb5_set_error_string) takes as an argument a
string. It sets the static buffer to contain that string (by
copying it, presumably).
The other function, krb5_get_error_string, returns [a copy of?]
this buffer.
This way, libraries never have to print error messages but can
still be precise. A library that calls a lower-level library
routine and percolates up the error code doesn't have to use
these routines. The error string is set only at the point where
the error actually occurs, and the error string is checked only
by the clients.
One could conceive of something like
if (kerror = function())
com_err(WHOAMI, kerror,
"%s while getting initial tickets", krb5_get_error_string());
if we decide to allow it to return a string, or some equivalent code
otherwise.
I think this system or something like it will result
in much more programmer-friendly code in general.
Comments?