home *** CD-ROM | disk | FTP | other *** search
Text File | 1986-09-06 | 2.0 KB | 74 lines | [TEXT/MACA] |
- /*
- * error.c - error notification routines
- */
-
- #include <quickdraw.h>
- #include <dialog.h>
- #include <toolutil.h>
- #include <memory.h>
- #include <syserr.h>
- #include <packages.h>
-
- #define ALTBOMB 401 /* Resource ID of our generic alert */
- #define DISKSTRS 401 /* System error strings */
- #define PROGSTRS 402 /* Program-specific error strings */
-
- static short errstr[] = { /* string # to error-number mapping */
- dirFulErr, dskFulErr, nsvErr, ioErr, bdNamErr,
- fnOpnErr, eofErr, posErr, mFulErr, tmfoErr,
- fnfErr, wPrErr, fLckdErr, vLckdErr, fBsyErr,
- dupFNErr, opWrErr, paramErr, rfNumErr, gfpErr,
- volOffLinErr, permErr, volOnLinErr, nsDrvErr, noMacDskErr,
- extFSErr, fsRnErr, badMDBErr, wrPermErr, memFullErr
- };
-
- static char msg[256]; /* the text to say */
-
- /*
- * diskerr() - given a system error number, notify the user of the error.
- */
- diskerr(err)
- OSErr err;
- {
- short sidx; /* index of the string to say */
-
- for (sidx = 1; sidx <= sizeof(errstr) / sizeof(errstr[0]); ++sidx) {
- if (errstr[sidx - 1] == err) break;
- }
- if (sidx <= sizeof(errstr) / sizeof(errstr[0])) {
- GetIndString(msg, DISKSTRS, sidx);
- } else {
- NumToString((long) err, msg);
- }
- ParamText(msg, (char *) 0, (char *) 0, (char *) 0);
- (void) StopAlert(ALTBOMB, (ProcPtr) 0);
- ResetAlrtStage();
- }
-
- /*
- * progstop(), prognote(), progcaution() - given a string ID from
- * the program's error strings, say that string inside a Stop, Note, or
- * Caution alert.
- */
- progstop(sidx) short sidx; { progmsg(sidx, stopIcon); }
- prognote(sidx) short sidx; { progmsg(sidx, noteIcon); }
- progcaution(sidx) short sidx; { progmsg(sidx, ctnIcon); }
-
- /*
- * progmsg() - server to progstop(), etc.
- */
- static
- progmsg(sidx, severity)
- short sidx;
- short severity;
- {
- GetIndString(msg, PROGSTRS, sidx);
- ParamText(msg, (char *) 0, (char *) 0, (char *) 0);
- switch (severity) {
- case stopIcon: (void) StopAlert(ALTBOMB, (ProcPtr) 0); break;
- case noteIcon: (void) StopAlert(ALTBOMB, (ProcPtr) 0); break;
- case ctnIcon: (void) StopAlert(ALTBOMB, (ProcPtr) 0); break;
- }
- ResetAlrtStage();
- }
-