src/tools/tError.cpp

Go to the documentation of this file.
00001 /*
00002 
00003 *************************************************************************
00004 
00005 ArmageTron -- Just another Tron Lightcycle Game in 3D.
00006 Copyright (C) 2000  Manuel Moos (manuel@moosnet.de)
00007 
00008 **************************************************************************
00009 
00010 This program is free software; you can redistribute it and/or
00011 modify it under the terms of the GNU General Public License
00012 as published by the Free Software Foundation; either version 2
00013 of the License, or (at your option) any later version.
00014 
00015 This program is distributed in the hope that it will be useful,
00016 but WITHOUT ANY WARRANTY; without even the implied warranty of
00017 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00018 GNU General Public License for more details.
00019 
00020 You should have received a copy of the GNU General Public License
00021 along with this program; if not, write to the Free Software
00022 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
00023   
00024 ***************************************************************************
00025 
00026 */
00027 
00028 #include "aa_config.h"
00029 #include <iostream>
00030 #include <string.h>
00031 #include <cstdlib>
00032 #if HAVE_UNISTD_H
00033 #include <unistd.h>
00034 #endif
00035 #include "tError.h"
00036 #include "tString.h"
00037 
00038 #ifdef DEBUG
00039 tLevel st_debugLevel[2]={static_cast<tLevel>(DEBUG),static_cast<tLevel>(DEBUG)};
00040 
00041 int st_debugValid(tLevel l,tChannel c) {
00042 
00043     return st_debugLevel[c]>=static_cast<int>(l) ;}
00044 #endif
00045 
00046 void st_Breakpoint(){
00047 #ifdef DEBUG
00048     std::cout << "Breakpoint!\n";
00049     int i=0; // a chance to get errors in GDB
00050     i++;
00051 #endif
00052 }
00053 
00054 #ifndef WIN32
00055 
00056 void st_PresentError( const char* caption, const char *message )
00057 {
00058     std::cerr << caption << ": " << message << "\n";
00059     st_Breakpoint();
00060     static bool error = true; // to disable the error if it is inconvenient right now and you think it may not be fatal
00061     if ( error )
00062     {
00063         throw 1; //tSimpleException( message, caption );
00064         exit(-1);
00065     }
00066 }
00067 
00068 void st_PresentMessage( const char* caption, const char *message )
00069 {
00070     std::cerr << caption << ": " << message << "\n";
00071     st_Breakpoint();
00072 }
00073 
00074 #else
00075 
00076 #include <windows.h>
00077 
00078 void st_PresentError( const char* caption, const char *message )
00079 {
00080     std::cerr << message;
00081 
00082 #ifdef DEBUG    
00083     int result = MessageBox (NULL, message , caption, MB_RETRYCANCEL);
00084 #else
00085 int result = MessageBox (NULL, message , caption, MB_OK);
00086 #endif
00087     switch ( result )
00088     {
00089     case IDRETRY:
00090     case IDYES:
00091         st_Breakpoint();
00092         break;
00093     case IDABORT:
00094     case IDOK:
00095     case IDCANCEL:
00096         throw 1;
00097         // exit(-1);
00098         break;
00099     }
00100 }
00101 
00102 void st_PresentMessage( const char* caption, const char *message )
00103 {
00104     std::cerr << message;
00105     MessageBox (NULL, message , caption, MB_OK);
00106 }
00107 
00108 #endif // WINDOWS
00109 
00110 char ERROR_MESSAGE[1000];
00111 

Generated on Sat Mar 15 22:56:00 2008 for Armagetron Advanced by  doxygen 1.5.4