00001 // This file is part of ff3d - http://www.freefem.org/ff3d 00002 // Copyright (C) 2004,2005 Stéphane Del Pino 00003 // 00004 // This program is free software; you can redistribute it and/or modify 00005 // it under the terms of the GNU General Public License as published by 00006 // the Free Software Foundation; either version 2, or (at your option) 00007 // any later version. 00008 // 00009 // This program is distributed in the hope that it will be useful, 00010 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 // GNU General Public License for more details. 00013 // 00014 // You should have received a copy of the GNU General Public License 00015 // along with this program; if not, write to the Free Software Foundation, 00016 // Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 00017 // 00018 // $Id: ErrorHandler.cpp,v 1.6 2007/05/20 23:05:47 delpinux Exp $ 00019 00020 #include <ErrorHandler.hpp> 00021 #include <StreamCenter.hpp> 00022 00023 #include <BaseName.hpp> 00024 00025 void ErrorHandler::writeErrorMessage() 00026 { 00027 switch(__type) { 00028 case asked: { 00029 fferr(3) << "\nremark: exit command explicitly called\n"; 00030 } 00031 case normal: { 00032 fferr(3) << '\n' << __filename << ':' << __lineNumber 00033 << ":remark: emitted the following message\n"; 00034 fferr(0) << "error: " << __errorMessage << '\n'; 00035 break; 00036 } 00037 case compilation: { 00038 fferr(0) << "\nline " << __lineNumber << ':' << __errorMessage << '\n'; 00039 break; 00040 } 00041 case unexpected: { 00042 fferr(0) << '\n' << __filename << ':' << __lineNumber << ":\n" << __errorMessage << '\n'; 00043 fferr(0) << "\nUNEXPECTED ERROR: this should not occure, please report it\n"; 00044 fferr(0) << "\nBUG REPORT: Please send bug reports to:\n" 00045 << " ff3d-dev@nongnu.org or freefem@ann.jussieu.fr\n" 00046 << "or better, use the Bug Tracking System:\n" 00047 << " http://savannah.nongnu.org/bugs/?group=ff3d\n"; 00048 break; 00049 } 00050 default: { 00051 fferr(0) << __filename << ':' << __lineNumber << ": " << __errorMessage << '\n'; 00052 fferr(0) << __FILE__ << ':' << __LINE__ << ":remark: error type not implemented!\n"; 00053 } 00054 } 00055 } 00056 00057 ErrorHandler:: 00058 ErrorHandler(const std::string& filename, 00059 const size_t& lineNumber, 00060 const std::string& errorMessage, 00061 const Type& type) 00062 : __filename(baseName(filename)), 00063 __lineNumber(lineNumber), 00064 __errorMessage(errorMessage), 00065 __type(type) 00066 { 00067 ; 00068 }
1.5.6