home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / std_unix / mod.std.unix.v1 / text0043.txt < prev    next >
Encoding:
Internet Message Format  |  1987-06-30  |  4.1 KB

  1. From: John Quarterman (moderator) <std-unix-request@ut-sally>
  2. Topic: standardized error messages
  3.  
  4. ----------------------------------------------------------------------
  5.  
  6. From: oakhill!mot!fred (Fred Christiansen)
  7. Date: Fri, 26 Jul 85 16:19:00 cdt
  8. To: oakhill!ut-sally!jsq@tzec.UTEXAS.ARPA
  9. Subject: Re: standardized error messages
  10.  
  11. the SVID has specifics in Appendix BASE 5.6 (p. 341), which i shall attempt
  12. to summarize:
  13.     the std error msg has 5 parts:
  14.         Label        who's issuing this msg
  15.         Severity    4 possible codes (halt, error, warning, fyi)
  16.         Problem        what went wrong
  17.         Action        "TO FIX" do such and such
  18.         Tag        unique error msg id which can be used to
  19.                 track down more info
  20.  
  21. Fred Christiansen ("Canajun, eh?") @ Motorola Microsystems, Tempe, AZ
  22. UUCP:  ihnp4!{attunix, btlunix, drivax, sftig, ut-sally!oakhill}!mot!fred
  23. ARPA:  oakhill!mot!fred@ut-sally.ARPA             AT&T:  602-438-3472
  24.  
  25. ------------------------------
  26.  
  27. From: Mike Trachtman  <wizard%wisdom.bitnet@WISCVM.ARPA>
  28. Date: Sun, 28 Jul 85 14:59:04 -0200
  29. To: std-unix@ut-sally.arpa
  30. Subject: standard error messages.
  31.  
  32. A standard for error messages should be very strict about punctuation,
  33. and where line numbers go.
  34. somthing like
  35.  
  36. command: filename (linenumber) - severity - message
  37.  
  38. this is getting kind of IBMsh, but programs should be able
  39. to parse errors, and thus errors should be in a standard form.
  40.  
  41. errors should definitely include the following
  42.  
  43. 1) the filename where the error was
  44. 2) the line number
  45. 3) the error, (or in greps case, the line that contained the word
  46.  
  47. optionally, but in a set format
  48.  
  49. 1) the command or routine that found the error
  50. 2) the Unix errno
  51. 3) some program generated error number
  52. 4) an indication of the severity
  53.  
  54. Of course, these are only opinions, and they are only my opinions.
  55. Mike
  56.  
  57.         wizard@wisdom                           (BITNET)
  58.         wizard%wisdom.bitnet@wiscvm.ARPA        (ARPA/CSNET)
  59.         wizard%wisdom.bitnet@berkley            (ARPA/CSNET)
  60. and if all else fails (ONLY for VERY short items)
  61.         ...!decvax!humus!wisdom!wizard          (UUCP)
  62.  
  63. ------------------------------
  64.  
  65. Date: Wed, 24 Jul 85 16:18:22 edt
  66. From: Chris Torek <chris@maryland>
  67. To: std-unix@ut-sally
  68. Subject: Re: standardized error messages
  69.  
  70. Hm.  It's probably too late, but I would suggest that any standard
  71. library routine for printing error message use printf-style
  72. conversions (preferably it should be exactly like printf once you
  73. get past severity stuff and whatnot).
  74.  
  75. In case anyone wants it, here's the routine I installed in our C
  76. library on our "experimental" machine (it wants a bit of support
  77. in the startup code to set _argv0 to argv[0], so that the program
  78. name is included in error messages, but will work without it).  It
  79. is not (alas!) portable, but can be made to work on any of the
  80. popular Unix machines.  (I have a manual entry, if anyone cares.)
  81.  
  82. Chris
  83.  
  84. #include <stdio.h>
  85.  
  86. char *_argv0;            /* argv[0], set by C startup code */
  87.  
  88. /*
  89.  * error - University of Maryland specific (sigh)
  90.  *
  91.  * Useful for printing error messages.  Will print the program name
  92.  * and (optionally) the system error associated with the values in
  93.  * <errno.h>.
  94.  *
  95.  * Note that the type (and even the existence!) of ``arg'' is undefined.
  96.  */
  97. error(quit, e, fmt, arg)
  98.     int quit;
  99.     register int e;
  100.     char *fmt;
  101. {
  102.     extern char *sys_errlist[];
  103.     extern int sys_nerr;
  104.     register char *p = _argv0;
  105.  
  106.     if (p != NULL) {
  107. #ifdef optional
  108.         char *s, *rindex();
  109.  
  110.         if ((s = rindex(p, '/')) != NULL)
  111.             p = s + 1;
  112. #endif
  113.         (void) fprintf(stderr, "%s: ", p);
  114.     }
  115.     _doprnt(fmt, &arg, stderr);    /* magic */
  116.     if (e > 0) {
  117.         p = e < sys_nerr ? sys_errlist[e] : "unknown error";
  118.         (void) fprintf(stderr, ": %s", p);
  119.     }
  120.     (void) putc('\n', stderr);
  121.     (void) fflush(stderr);
  122.     if (quit)
  123.         exit(quit);
  124. }
  125.  
  126. ------------------------------
  127.  
  128. Discussions-Of: UNIX standards, particularly the IEEE P1003 draft standard.
  129. Submissions-To:    ut-sally!std-unix    or std-unix@ut-sally.ARPA
  130. Comments-To: ut-sally!std-unix-request    or std-unix-request@ut-sally.ARPA
  131. UUCP-Routes: {ihnp4,seismo,harvard,gatech}!ut-sally!std-unix
  132. Archives-In: ~ftp/pub/mod.std.unix on ut-sally.ARPA (soon sally.UTEXAS.EDU)
  133.  
  134.  
  135.  
  136. Volume-Number: Volume 1, Number 44
  137.  
  138.