Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Related Pages  

LOW_exception.cpp

Go to the documentation of this file.
00001 /***************************************************************************
00002                           LOW_exception.cpp  -  description
00003                              -------------------
00004     begin                : Sat Jul 6 2002
00005     copyright            : (C) 2002 by Harald Roelle, Helmut Reiser
00006     email                : roelle@informatik.uni-muenchen.de, reiser@informatik.uni-muenchen.de
00007  ***************************************************************************/
00008 
00009 /***************************************************************************
00010  *                                                                         *
00011  *   This program is free software; you can redistribute it and/or modify  *
00012  *   it under the terms of the GNU General Public License as published by  *
00013  *   the Free Software Foundation; either version 2 of the License, or     *
00014  *   (at your option) any later version.                                   *
00015  *                                                                         *
00016  ***************************************************************************/
00017 
00018 
00019 #include "LOW_exception.h"
00020 #include "LOW_helper_msglog.h"
00021 
00022 
00023 //=====================================================================================
00024 //
00025 // static attributes
00026 //
00027 
00028 bool LOW_exception::logOnCreation = false;
00029 
00030 
00031 //=====================================================================================
00032 //
00033 // constructors
00034 //
00035 
00036 LOW_exception::LOW_exception() :
00037   errNum( 0),
00038   message( "")
00039 {
00040 }
00041 
00042 LOW_exception::LOW_exception( const std::string inMsg, const std::string inFile, const int inLine) : 
00043   errNum( 0),
00044   message( inMsg),
00045   file( inFile),
00046   line( inLine)
00047 {
00048   if ( logOnCreation )
00049     logException( "[auto-logged on creation] ");
00050 }
00051 
00052 LOW_exception::LOW_exception( const int inErrNum, const std::string inMsg, const std::string inFile, const int inLine) : 
00053   errNum( inErrNum),
00054   message( inMsg),
00055   file( inFile),
00056   line( inLine)
00057 {
00058   if ( logOnCreation )
00059     logException( "[auto-logged on creation] ");
00060 }
00061 
00062 LOW_exception::~LOW_exception()
00063 {
00064 }
00065   
00066   
00067 //=====================================================================================
00068 //
00069 // static methods
00070 //
00071 
00072 void LOW_exception::setLogOnCreation( const bool inLogOnCreation)
00073 {
00074   logOnCreation = inLogOnCreation;
00075 }
00076 
00077 
00078 bool LOW_exception::getLogOnCreation()
00079 {
00080   return logOnCreation;
00081 }
00082     
00083 
00084 //=====================================================================================
00085 //
00086 // static methods
00087 //
00088 
00089 void LOW_exception::logException( const std::string inPrefix)
00090 {
00091   if ( errNum == 0 )
00092     LOW_helper_msglog::printError( "%s%s {file: %s, line: %d}", inPrefix.c_str(), message.c_str(), file.c_str(), line);
00093   else
00094     LOW_helper_msglog::printPerror( errNum, "%s%s {file: %s, line: %d}", inPrefix.c_str(), message.c_str(), file.c_str(), line);
00095 }

Generated on Sun Jan 12 21:07:43 2003 by doxygen1.2.13.1 written by Dimitri van Heesch, © 1997-2001