ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/common/error.c
(Generate patch)

Comparing ray/src/common/error.c (file contents):
Revision 2.3 by gregl, Wed May 28 17:23:31 1997 UTC vs.
Revision 2.4 by gregl, Tue Nov 11 19:02:15 1997 UTC

# Line 14 | Line 14 | static char SCCSid[] = "$SunId$ LBL";
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  
# Line 22 | Line 24 | error(etype, emsg)             /* report error, quit if necessary
24   int  etype;
25   char  *emsg;
26   {
27 <        switch (etype) {
28 <        case WARNING:
29 <                wputs("warning - ");
28 <                wputs(emsg);
29 <                wputs("\n");
27 >        register struct erract  *ep;
28 >
29 >        if (etype < 0 | etype >= NERRS)
30                  return;
31 <        case COMMAND:
32 <                cputs(emsg);
33 <                cputs("\n");
34 <                return;
35 <        case USER:
36 <                eputs("fatal - ");
37 <                eputs(emsg);
38 <                eputs("\n");
39 <                quit(1);
40 <        case INTERNAL:
41 <                eputs("internal - ");
42 <                eputs(emsg);
43 <                eputs("\n");
44 <                quit(1);
45 <        case SYSTEM:
46 <                eputs("system - ");
47 <                eputs(emsg);
48 <                if (errno > 0) {
49 <                        eputs(": ");
31 >        ep = erract + etype;
32 >        if (ep->pf != NULL) {
33 >                (*ep->pf)(ep->pre);
34 >                (*ep->pf)(emsg);
35 >                if (etype == SYSTEM && errno > 0) {
36 >                        (*ep->pf)(": ");
37                          if (errno <= sys_nerr)
38 <                                eputs(sys_errlist[errno]);
38 >                                (*ep->pf)(sys_errlist[errno]);
39                          else
40 <                                eputs("Unknown error");
40 >                                (*ep->pf)("Unknown error");
41                  }
42 <                eputs("\n");
56 <                quit(2);
57 <        case CONSISTENCY:
58 <                eputs("consistency - ");
59 <                eputs(emsg);
60 <                eputs("\n");
61 <                abort();
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   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines