GME
13
|
00001 #include "stdafx.h" 00002 #include ".\DomErrorPrinter.h" 00003 #include <xercesc/dom/DOMLocator.hpp> 00004 #include <xercesc/util/XMLString.hpp> 00005 #include "MsgConsole.h" 00006 #include "xml_smart_ptr.h" 00007 //#include "Transcoder.h" 00008 00009 using namespace XERCES_CPP_NAMESPACE; 00010 00011 bool DOMErrorPrinter::handleError(const DOMError &domError) 00012 { 00013 msgtype_enum mt; 00014 bool fatal = false; 00015 00016 if( domError.getSeverity() == DOMError::DOM_SEVERITY_WARNING) 00017 mt = MSG_WARNING; 00018 else if( domError.getSeverity() == DOMError::DOM_SEVERITY_ERROR) 00019 mt = MSG_ERROR; 00020 else 00021 fatal = true, mt = MSG_ERROR; 00022 00023 // general message 00024 smart_Ch e_msg = XMLString::transcode(domError.getMessage()); 00025 std::string msg = std::string( fatal? "[Fatal Error] ": "") + e_msg; 00026 00027 // send msg 00028 if( m_consolePtr) m_consolePtr->sendMsg( msg, mt); 00029 00030 00031 // location info available? 00032 DOMLocator* loc = domError.getLocation(); 00033 if( loc) 00034 { 00035 char line_nmbs[256]; 00036 memset( line_nmbs, 0, sizeof(line_nmbs)); 00037 00038 smart_Ch f_str = XMLString::transcode(loc->getURI()); 00039 sprintf( line_nmbs, "Line: %u Column: %u of File: ", (unsigned)loc->getLineNumber(), (unsigned)loc->getColumnNumber()); 00040 std::string linfo = std::string( line_nmbs) + f_str; 00041 00042 // send msg 00043 if( m_consolePtr) m_consolePtr->sendMsg( linfo, mt); 00044 } 00045 00046 // Instructs the serializer to continue serialization if possible. 00047 return true; 00048 }