00001 // Copyright (C) 2004 Bernhard Assmann <bernie@tuxomania.net> 00002 // 00003 // This program is free software; you can redistribute it and/or modify 00004 // it under the terms of the GNU General Public License as published by 00005 // the Free Software Foundation; either version 2 of the License, or 00006 // (at your option) any later version. 00007 // 00008 // This program is distributed in the hope that it will be useful, 00009 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00010 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00011 // GNU General Public License for more details. 00012 // 00013 // You should have received a copy of the GNU General Public License 00014 // along with this program; if not, write to the Free Software 00015 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 00016 // 00017 00018 #include <xercesc/util/XMLString.hpp> 00019 #include "psfa/ConfigSax2ErrorHandler.hpp" 00020 00021 #include <iostream> 00022 #include <sstream> 00023 00024 00025 00026 psfa::ConfigSax2ErrorHandler::ConfigSax2ErrorHandler() 00027 : error_("") 00028 { 00029 00030 } 00031 00032 00033 00034 void 00035 psfa::ConfigSax2ErrorHandler::error( const xercesc::SAXParseException &exception ) 00036 { 00037 addError( "Fehler", exception ); 00038 std::cerr << error_ << std::endl; 00039 return; 00040 } 00041 00042 00043 00044 void 00045 psfa::ConfigSax2ErrorHandler::fatalError( const xercesc::SAXParseException &exception ) 00046 { 00047 addError( "Fataler Fehler", exception ); 00048 std::cerr << error_ << std::endl; 00049 return; 00050 } 00051 00052 00053 00054 void 00055 psfa::ConfigSax2ErrorHandler::warning( const xercesc::SAXParseException &exception ) 00056 { 00057 addError( "Warnung", exception ); 00058 std::cerr << error_ << std::endl; 00059 return; 00060 } 00061 00062 00063 00064 void 00065 psfa::ConfigSax2ErrorHandler::resetErrors() 00066 { 00067 error_ = ""; 00068 return; 00069 } 00070 00071 00072 00073 void 00074 psfa::ConfigSax2ErrorHandler::addError( std::string message, 00075 const xercesc::SAXParseException& exception 00076 ) 00077 { 00078 using xercesc::XMLString; 00079 00080 std::ostringstream err; 00081 err << message 00082 << " in der Datei:\n" 00083 << XMLString::transcode(exception.getSystemId()) 00084 << ",\n Zeile " 00085 << exception.getLineNumber() 00086 << ", Zeichen " 00087 << exception.getColumnNumber() 00088 << ",\nArt:\n" 00089 << XMLString::transcode(exception.getMessage()); 00090 00091 error_ += err.str(); 00092 00093 return; 00094 }