ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/common/error.c
Revision: 2.5
Committed: Tue Dec 2 15:54:44 1997 UTC (26 years, 5 months ago) by gregl
Content type: text/plain
Branch: MAIN
Changes since 2.4: +2 -2 lines
Log Message:
avoid calls to output empty strings

File Contents

# Content
1 /* Copyright (c) 1991 Regents of the University of California */
2
3 #ifndef lint
4 static char SCCSid[] = "$SunId$ LBL";
5 #endif
6
7 /*
8 * error.c - standard error reporting function
9 */
10
11 #include "standard.h"
12
13 #ifndef linux
14 extern char *sys_errlist[]; /* system error list */
15 extern int sys_nerr; /* number of system errors */
16 #endif
17 /* global list of error actions */
18 struct erract erract[NERRS] = ERRACT_INIT;
19
20 char errmsg[512]; /* global error message buffer */
21
22
23 error(etype, emsg) /* report error, quit if necessary */
24 int etype;
25 char *emsg;
26 {
27 register struct erract *ep;
28
29 if (etype < 0 | etype >= NERRS)
30 return;
31 ep = erract + etype;
32 if (ep->pf != NULL) {
33 if (ep->pre[0]) (*ep->pf)(ep->pre);
34 if (emsg != NULL && emsg[0]) (*ep->pf)(emsg);
35 if (etype == SYSTEM && errno > 0) {
36 (*ep->pf)(": ");
37 if (errno <= sys_nerr)
38 (*ep->pf)(sys_errlist[errno]);
39 else
40 (*ep->pf)("Unknown error");
41 }
42 (*ep->pf)("\n");
43 }
44 if (!ep->ec) /* non-fatal */
45 return;
46 if (ep->ec < 0) /* dump core */
47 abort();
48 quit(ep->ec); /* quit calls exit after cleanup */
49 }