1 /*****************************************************************************
2 ** This is part of the CTSim program
3 ** Copyright (C) 1983-2000 Kevin Rosenberg
5 ** $Id: syserror.cpp,v 1.1 2000/06/19 02:58:08 kevin Exp $
7 ** This program is free software; you can redistribute it and/or modify
8 ** it under the terms of the GNU General Public License (version 2) as
9 ** published by the Free Software Foundation.
11 ** This program is distributed in the hope that it will be useful,
12 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
13 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 ** GNU General Public License for more details.
16 ** You should have received a copy of the GNU General Public License
17 ** along with this program; if not, write to the Free Software
18 ** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 ******************************************************************************/
29 * sys_error System error handler
32 * sys_error (severity, msg, args . . .)
33 * int severity Severity of error
34 * char *msg Error message
35 * args Argument list, direct transfer to printf stack
36 * Can take 24 byte transfer
39 static int errorlevel = ERR_WARNING; /* Set error reporting level */
42 void sys_error (int severity, const char *msg, ...)
48 sys_verror (severity, msg, arg);
53 static int nErrorCount = 0;
54 const static int MAX_ERROR_COUNT = 20;
57 void sys_verror (int severity, const char *msg, va_list arg)
59 if (severity < errorlevel)
60 return; /* ignore error if less than max level */
63 if (severity != ERR_FATAL) {
64 if (nErrorCount > MAX_ERROR_COUNT)
66 else if (nErrorCount == MAX_ERROR_COUNT) {
67 cout << "*****************************************************************" << endl;
68 cout << "*** M A X I M U M E R R O R C O U N T R E A C H E D ***" << endl;
69 cout << "*** ***" << endl;
70 cout << "*** No further errors will be reported ***" << endl;
71 cout << "*****************************************************************" << endl;
78 cout << "FATAL ERROR: ";
81 cout << "SEVERE ERROR: ";
84 cout << "WARNING ERROR: ";
87 sys_error (ERR_FATAL, "illegal error code #%d [sys_error]", severity);
90 vfprintf (stdout, msg, arg);
94 if (severity == ERR_FATAL)
97 #if INTERACTIVE_ERROR_DISPLAY
98 cout << "A - Abort C - Continue W - Turn off warnings? ";
102 int c = cio_kb_waitc("AaBbCcWw", TRUE); /* get code from keyboard */
105 fputc (NEWLINE, stderr);
113 sys_error_level (ERR_SEVERE); /* report severe & fatal errors */
122 * sys_error_level Set error reporting level
125 * sys_error_level (severity)
126 * int severity Report all error as serious as severity and beyond
129 * Causes the system to ignore all error below the level of severity
130 * For example, if severity == ERR_SEVERE, then report severe & fatal
131 * error and ignore warnings
135 sys_error_level (int severity)
137 if (severity == ERR_FATAL ||
138 severity == ERR_SEVERE ||
139 severity == ERR_WARNING)
140 errorlevel = severity;
142 errorlevel = ERR_WARNING;