friendly messages
Peter da Silva
peter at ficc.uu.net
Tue Mar 7 00:05:50 AEST 1989
In article <9780 at smoke.BRL.MIL>, gwyn at smoke.BRL.MIL (Doug Gwyn ) writes:
> In article <3283 at ficc.uu.net> peter at ficc.uu.net (Peter da Silva) writes:
> >Have you looked at the new "perror()" docs? They describe a 4-component
> >error message format for all programs to use...
> perror() CANNOT do this, as its interface is standardized and has no
> room for the additional information (severity and object; the program
> name can and probably should be automated).
I realise this. The document describes what programs should do for error
messages, but makes no recommendation as to how this should be done.
> Presumably there is an
> analogous function that accepts the additional information.
Unfortunately it's like Open Look... they just specced what it should look
like without providing a programmer interface. The documentation has been
out in the bookstores for some time: it's a red book with a plastic spiral
binding.
> What is supposed to be done when there is no particular object?
> prog: fatal: ???: Insufficient memory available
What does perror do when there is no particular object?
if(!(buffer = malloc(BUFSIZ*NUMBUFS))) {
perror(.....?.....);
...
}
Same problem.
Perhaps we (the usenet community) should spec a better interface:
extern char *progname;
extern char *errformat;
extern char default_errformat[];
char *errmsg();
main(argc, argv)
int argc;
char **argv;
{
progname = argv[0];
errformat = getenv("ERRORFORMAT");
if(errformat == NULL)
errformat = default_errformat;
...
}
...
fprintf(stderr, "%s\n", errmsg(object, severity));
errformat would be printf/sccs-like:
%p program name
%P program name, tail only (no path).
%o object
%e error message
%E short error message
%s severity
%S severity, 1 char
%E %p: %s: %o: %e
%Q %o: %e
--
Peter da Silva, Xenix Support, Ferranti International Controls Corporation.
Work: uunet.uu.net!ficc!peter, peter at ficc.uu.net, +1 713 274 5180. `-_-'
Home: ...!texbell!sugar!peter, peter at sugar.hackercorp.com. 'U`
People have opinions. Companies have policy. And typos are my own business.
More information about the Comp.unix.wizards
mailing list