|
From: <mk...@us...> - 2003-04-12 22:34:37
|
Update of /cvsroot/csp/APPLICATIONS/CSPSim/Source In directory sc8-pr-cvs1:/tmp/cvs-serv3057/Source Modified Files: CSPSim.cpp Makefile.in Sky.cpp Added Files: Exception.cpp Log Message: see CHANGES.current --- NEW FILE: Exception.cpp --- // Combat Simulator Project - FlightSim Demo // Copyright (C) 2002 The Combat Simulator Project // http://csp.sourceforge.net // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License // as published by the Free Software Foundation; either version 2 // of the License, or (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. /** * @file Exception.cpp * **/ #include "Exception.h" #include "LogStream.h" #include <cstdio> #include <iostream> #include "DemeterException.h" #include <SimData/Exception.h> namespace csp { void FatalException(Exception &e, std::string const &location) { DataError *pDataError = dynamic_cast<DataError*> (&e); CSP_LOG(CSP_APP, CSP_ERROR, "CSPSim: caught exception in " << location << ": " << e.getMessage()); std::cerr << "\n"; e.details(); std::cerr << "\n"; if (pDataError) { std::cerr << "Please check that the data paths in CSPSim.ini are set to reasonable\n" << "values (CSPSim.ini is usually found in CSPSim/Data). If you appear\n" << "to be missing a necessary data file, please check the CSP download\n" << "page for the latest data releases or ask for assistance on the CSP\n" << "forums:\n" << " http://csp.sourceforge.net/forum\n"; } else { std::cerr << "CSPSim: caught an exception. Please report this along with\n" << "as much information as possible about what was happening at \n" << "the time of the error to the CSP forum at\n" << " http://csp.sourceforge.net/forum\n"; } std::cerr << "\n"; ::exit(1); } void DemeterFatalException(DemeterException &e, std::string const &location) { CSP_LOG(CSP_APP, CSP_ERROR, "CSPSim: caught Demeter exception in " << location << ": " << e.GetErrorMessage()); std::cerr << "\n"; std::cerr << "CSPSim: caught an Demeter exception. Please report this along\n" << "with as much information as possible about what was happening at \n" << "the time of the error to the CSP forum at\n" << " http://csp.sourceforge.net/forum\n"; std::cerr << "\n"; ::exit(1); } void SimDataFatalException(simdata::Exception &e, std::string const &location) { CSP_LOG(CSP_APP, CSP_ERROR, "CSPSim: caught SimData exception in " << location << ": " << e.getMessage()); std::cerr << "\n"; e.details(); std::cerr << "\n"; std::cerr << "CSPSim: caught an SimData exception. Please report this along\n" << "with as much information as possible about what was happening at \n" << "the time of the error to the CSP forum at\n" << " http://csp.sourceforge.net/forum\n" << "If you built CSPSim from CVS, you may wish to check that your\n" << "installed version of SimData is also the latest available from\n" << "CVS.\n"; std::cerr << "\n"; ::exit(1); } void OtherFatalException(std::string const &location) { CSP_LOG(CSP_APP, CSP_ERROR, "CSPSim: caught unknown exception in " << location << "."); std::cerr << "\n"; std::cerr << "CSPSim: caught an (unknown) exception. Please report this along\n" << "with as much information as possible about what was happening at \n" << "the time of the error to the CSP forum at\n" << " http://csp.sourceforge.net/forum\n"; std::cerr << "\n"; ::exit(1); } } // namespace csp Index: CSPSim.cpp =================================================================== RCS file: /cvsroot/csp/APPLICATIONS/CSPSim/Source/CSPSim.cpp,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** CSPSim.cpp 12 Apr 2003 00:55:04 -0000 1.20 --- CSPSim.cpp 12 Apr 2003 22:34:34 -0000 1.21 *************** *** 40,43 **** --- 40,44 ---- #include "CSPSim.h" #include "EventMapIndex.h" + #include "Exception.h" #include "GameScreen.h" #include "HID.h" *************** *** 283,297 **** logoScreen.OnExit(); } ! catch(DemeterException * pEx) { ! CSP_LOG(CSP_APP, CSP_ERROR, "CSPSim: caught Demeter exception during initialazation: " << pEx->GetErrorMessage()); ! ::exit(1); } ! catch(simdata::Exception * pEx) { ! CSP_LOG(CSP_APP, CSP_ERROR, "CSPSim: caught SimData exception during initialization: " << pEx->getMessage()); ! ::exit(1); } catch (...) { ! CSP_LOG(CSP_APP, CSP_ERROR, "CSPSim: caught unknown exception during initialazation."); ! ::exit(1); } } --- 284,298 ---- logoScreen.OnExit(); } ! catch(csp::Exception & pEx) { ! csp::FatalException(pEx, "initialization"); } ! catch(DemeterException & pEx) { ! csp::DemeterFatalException(pEx, "initialization"); ! } ! catch(simdata::Exception & pEx) { ! csp::SimDataFatalException(pEx, "initialization"); } catch (...) { ! csp::OtherFatalException("initialization"); } } Index: Makefile.in =================================================================== RCS file: /cvsroot/csp/APPLICATIONS/CSPSim/Source/Makefile.in,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** Makefile.in 12 Apr 2003 01:25:31 -0000 1.11 --- Makefile.in 12 Apr 2003 22:34:34 -0000 1.12 *************** *** 33,36 **** --- 33,37 ---- EventMapIndex.cpp \ EventMapping.cpp \ + Exception.cpp \ F16Model.cpp \ GameScreen.cpp \ Index: Sky.cpp =================================================================== RCS file: /cvsroot/csp/APPLICATIONS/CSPSim/Source/Sky.cpp,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** Sky.cpp 11 Apr 2003 18:59:20 -0000 1.9 --- Sky.cpp 12 Apr 2003 22:34:34 -0000 1.10 *************** *** 33,36 **** --- 33,37 ---- #include "Config.h" #include "Colorspace.h" + #include "Exception.h" #include <cmath> *************** *** 542,546 **** x = y = 1.0; m_Image = osgDB::readImageFile("moon.png"); ! assert(m_Image.valid()); // set up the texture. --- 543,547 ---- x = y = 1.0; m_Image = osgDB::readImageFile("moon.png"); ! if (!m_Image.valid()) throw csp::DataError("unable to open \"moon.png\""); // set up the texture. |