[net.unix-wizards] Cryptic Error Messages from system programs

idallen (07/30/82)

terryl@sri-unix mentions finding a bug in writei (teklabs.1301) because
he investigated an error message from fsck.  I note with interest that
he didn't understand the error message, but had to do research into the
code to find out what it meant.  Why is this research necessary?  Why
haven't these programs been written to produce readable messages right
from the start?  I guess it's a case of "hack" programs being used by
non-hack maintenance people.  Moral: never assume your program will
only be used by people that know what they are doing.

A related issue concerns error messages that hide details.
I've seen code that resembles:

	if( strlen(filename) > NAMELENGTH ){
		fprintf( stderr, "Bad file name." );
		exit( 1 );
	}

Not only is the name of the program issuing the error unidentified,
but no information is given about *which* file name is in error, or 
what the nature of the error is.  So much time can be saved by a
little forethought:

	if( strlen(filename) > NAMELENGTH ){
		fprintf( stderr, "%s: file name '%s' longer than %d characters.",
			cmdname, filename, NAMELENGTH );
		exit( 1 );
	}

	-IAN!   U of Waterloo   (decvax!watmath!idallen)