r192: *** empty log message ***
[ctsim.git] / libctsupport / syserror.cpp
index dc3851cbbffb8507884ca8129ed7508d962ae683..6d0900dcda89511de3eb3c7c3286246bb7ce78b1 100644 (file)
@@ -2,7 +2,7 @@
 **  This is part of the CTSim program
 **  Copyright (C) 1983-2000 Kevin Rosenberg
 **
-**  $Id: syserror.cpp,v 1.1 2000/06/19 02:58:08 kevin Exp $
+**  $Id: syserror.cpp,v 1.6 2000/09/07 04:31:41 kevin Exp $
 **
 **  This program is free software; you can redistribute it and/or modify
 **  it under the terms of the GNU General Public License (version 2) as
 ******************************************************************************/
 
 #include <iostream>
+#include <exception>
+#include <stdexcept>
 #include <stdarg.h>
 #include <ctype.h>
-#include "kstddef.h"
-#include "cio.h"
+#include "ctsupport.h"
 
 
 /* NAME
@@ -57,7 +58,7 @@ const static int MAX_ERROR_COUNT = 20;
 void sys_verror (int severity, const char *msg, va_list arg)
 {
   if (severity < errorlevel)
-    return;                    /* ignore error if less than max level */
+    return;    // ignore error if less than max level
 
   nErrorCount++;
   if (severity != ERR_FATAL) {
@@ -65,7 +66,7 @@ void sys_verror (int severity, const char *msg, va_list arg)
       return;
     else if (nErrorCount == MAX_ERROR_COUNT) {
       cout << "*****************************************************************" << endl;
-      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;
+      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;
       cout << "***                                                           ***" << endl;
       cout << "***           No further errors will be reported              ***" << endl;
       cout << "*****************************************************************" << endl;
@@ -84,15 +85,20 @@ void sys_verror (int severity, const char *msg, va_list arg)
     cout << "WARNING ERROR: ";
     break;
   default:
-    sys_error (ERR_FATAL, "illegal error code #%d  [sys_error]", severity);
+    cout << "Illegal error code #" << severity << ": ";
   }
   
-  vfprintf (stdout, msg, arg);
+  char errStr[512];
+#if HAVE_VSNPRINTF
+  vsnprintf (errStr, sizeof(errStr), msg, arg);
+#elif HAVE_VSPRINTF
+  vsprintf (errStr, msg, arg);
+#endif
 
-  cout << "\n";
+  cout << errStr << endl;
   
   if (severity == ERR_FATAL)
-    exit(1);
+    throw runtime_error (errStr);
   
 #if INTERACTIVE_ERROR_DISPLAY
   cout << "A - Abort  C - Continue  W - Turn off warnings? ";