00001
00002
00003
00004
00005
00006
00007
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040 # include "flow/xmlstreamconsumer.hpp"
00041 # include "processor/xmlflowexception.hpp"
00042 # include "flow/xmlstreambuffer.hpp"
00043
00044 BEGIN_XDFLENGINE_NS
00045
00046
00047
00048
00049
00050
00051
00052
00053 void XMLFlowException::throwXMLFlowException(int p_intNumber, const char* p_pszMessage, const char* p_pszContext, const char* p_pszLocalisation, const char* p_pszCause, bool p_boolFatal)
00054 {
00055 throw new XMLFlowException(p_intNumber, p_pszMessage, p_pszContext, p_pszLocalisation, p_pszCause, p_boolFatal);
00056 }
00057
00058
00059
00060
00061 XMLFlowException::XMLFlowException(int p_intNumber, const char* p_pszMessage, const char* p_pszContext, const char* p_pszLocalisation, const char* p_pszCause, bool p_boolFatal)
00062 {
00063
00064 logout << "\n";
00065 if (p_boolFatal) logout << "FATAL ";
00066 logout << "ERROR #" << p_intNumber << " in "<< p_pszLocalisation << " :" << "\n";
00067 logout << p_pszMessage << "\n";
00068 logout << p_pszContext << "\n";
00069
00070 m_intErrNumber = p_intNumber;
00071 m_pszErrMessage = importCharBuffer(0,p_pszMessage);
00072 m_pszErrContext = importCharBuffer(0,p_pszContext);
00073 m_pszErrLocalisation = importCharBuffer(0,p_pszLocalisation);
00074 m_pszErrCause = importCharBuffer(0,p_pszCause);
00075 m_boolFatal = p_boolFatal;
00076
00077 if(!m_boolFatal)
00078 {
00079 DEBUG_CREATE(******XMLFLOWEXCEPTION******)
00080 }
00081 else
00082 {
00083 DEBUG_CREATE(******FATAL XMLFLOWEXCEPTION******)
00084 }
00085
00086 DEBUG_ECHO << "SENDER: " << p_pszLocalisation << "\n";
00087 }
00088
00089
00090
00091
00092 XMLFlowException::~XMLFlowException()
00093 {
00094 if(!m_boolFatal)
00095 {
00096 DEBUG_DEL(******XMLFLOWEXCEPTION******)
00097 }
00098 else
00099 {
00100 DEBUG_DEL(******FATAL XMLFLOWEXCEPTION******)
00101 }
00102 m_pszErrMessage = releaseCharBuffer( m_pszErrMessage);
00103 m_pszErrContext = releaseCharBuffer( m_pszErrContext);
00104 m_pszErrLocalisation = releaseCharBuffer( m_pszErrLocalisation);
00105 m_pszErrCause = releaseCharBuffer( m_pszErrCause);
00106 }
00107
00108
00109
00110
00111 bool XMLFlowException::isFatal()
00112 {
00113 return m_boolFatal;
00114 }
00115
00116
00117
00118
00119
00121
00123
00124 int XMLFlowException::getNumber()
00125 {
00126 return m_intErrNumber;
00127 }
00128
00129
00130
00131
00132 XMLFlowException& XMLFlowException::operator>> (XMLStreamConsumer & p_Output)
00133 {
00134 char l_cErrNum[10];
00135
00136 sprintf( l_cErrNum, "%d",m_intErrNumber);
00137
00138 if(!m_boolFatal) p_Output << "\n<ERROR>";
00139 else p_Output << "\n<FATAL_ERROR>";
00140
00141 p_Output << "\n\t<number>" << l_cErrNum << "</number>";
00142 p_Output << "\n\t<message><![CDATA[" << m_pszErrMessage << "]]></message>";
00143 p_Output << "\n\t<localisation><![CDATA[" << m_pszErrLocalisation << "]]></localisation>";
00144 p_Output << "\n\t<context><![CDATA[" << m_pszErrContext << "]]></context>";
00145 p_Output << "\n\t<cause><![CDATA[" << m_pszErrCause << "]]></cause>";
00146
00147 if(!m_boolFatal) p_Output << "\n</ERROR>\n";
00148 else p_Output << "\n</FATAL_ERROR>";
00149
00150 return (* this);
00151 }
00152
00153
00154
00155
00156
00157
00158
00159
00160
00161
00162
00163
00164
00165
00166
00167 XDFLSaxErrorReporter::XDFLSaxErrorReporter(const char* p_pszParseName)
00168 {
00169 resetErrors();
00170 m_pszParseName = importCharBuffer(0,p_pszParseName);
00171
00172 DEBUG_CREATE(XDFLSaxErrorReporter)
00173 }
00174
00175
00176
00177
00178 XDFLSaxErrorReporter::~XDFLSaxErrorReporter()
00179 {
00180 DEBUG_DEL(XDFLSaxErrorReporter)
00181
00182 m_pszParseName = releaseCharBuffer(m_pszParseName);
00183 }
00184
00185
00186
00187
00188
00189
00190 void XDFLSaxErrorReporter::warning(const SAXParseException& toCatch)
00191 {
00192 DEBUG_FUNC(XDFLSaxErrorReporter::warning)
00193 }
00194
00195
00196
00197
00198 void XDFLSaxErrorReporter::error(const SAXParseException& toCatch)
00199 {
00200 XMLFlowException* l_pXMLFlowException;
00201 char* l_pszMsg;
00202 char* l_pszTmp;
00203
00204 DEBUG_FUNC(XDFLSaxErrorReporter::error)
00205
00206 fSawErrors = true;
00207 l_pszMsg = copyCharBuffer( "XML Error at file ");
00208
00209 l_pszTmp = XSTR( toCatch.getSystemId());
00210 l_pszMsg = concatCharBuffer( l_pszMsg,l_pszTmp);
00211 l_pszTmp = releaseCharBuffer(l_pszTmp);
00212
00213 l_pszMsg = concatCharBuffer( l_pszMsg,":");
00214
00215 l_pszTmp = XSTR( toCatch.getMessage());
00216 l_pszMsg = concatCharBuffer( l_pszMsg,l_pszTmp);
00217 l_pszTmp = releaseCharBuffer(l_pszTmp);
00218
00219 l_pXMLFlowException=new XMLFlowException ( ERRCODE_LOC_OTHERS + ERRCODE_CAUSE_XML , l_pszMsg, m_pszParseName, "XDFLSaxErrorReporter", "", false);
00220 l_pszMsg = releaseCharBuffer(l_pszMsg);
00221 throw l_pXMLFlowException;
00222
00223 }
00224
00225
00226
00227
00228 void XDFLSaxErrorReporter::fatalError(const SAXParseException& toCatch)
00229 {
00230 XMLFlowException* l_pXMLFlowException;
00231 char* l_pszMsg;
00232 char* l_pszTmp;
00233
00234 DEBUG_FUNC(XDFLSaxErrorReporter::error)
00235
00236 fSawErrors = true;
00237 l_pszMsg = copyCharBuffer( "Fatal XML Error at file ");
00238
00239 l_pszTmp = XSTR( toCatch.getSystemId());
00240 l_pszMsg = concatCharBuffer( l_pszMsg,l_pszTmp);
00241 l_pszTmp = releaseCharBuffer(l_pszTmp);
00242
00243 l_pszMsg = concatCharBuffer( l_pszMsg,":");
00244
00245 l_pszTmp = XSTR( toCatch.getMessage());
00246 l_pszMsg = concatCharBuffer( l_pszMsg,l_pszTmp);
00247 l_pszTmp = releaseCharBuffer(l_pszTmp);
00248
00249 logout << "(" << (int)(toCatch.getLineNumber()) << "," << (int)(toCatch.getColumnNumber()) << ")\n";
00250
00251 l_pXMLFlowException=new XMLFlowException ( ERRCODE_LOC_OTHERS + ERRCODE_CAUSE_XML , l_pszMsg, m_pszParseName, "XDFLSaxErrorReporter", "", false);
00252 l_pszMsg = releaseCharBuffer(l_pszMsg);
00253 throw l_pXMLFlowException;
00254 }
00255
00256
00257
00258
00259 void XDFLSaxErrorReporter::resetErrors()
00260 {
00261 DEBUG_FUNC(DOMTreeErrorReporter::resetErrors)
00262
00263 fSawErrors=false;
00264 }
00265
00266
00267
00268
00269
00270
00271 bool XDFLSaxErrorReporter::getSawErrors()
00272 {
00273 DEBUG_FUNC(DOMTreeErrorReporter::getSawErrors)
00274
00275 return fSawErrors;
00276 }
00277
00278
00279
00280
00281 END_XDFLENGINE_NS
00282