Bug 279814 - report XML parsing errors to the JS console, r=mrbkap sr=shaver a=chofmann

This commit is contained in:
bsmedberg%covad.net 2005-06-23 01:54:42 +00:00
Родитель 8da4b63af0
Коммит a7a996bfe8
3 изменённых файлов: 20 добавлений и 1 удалений

Просмотреть файл

@ -64,6 +64,7 @@ REQUIRES = xpcom \
pref \ pref \
nkcache \ nkcache \
intl \ intl \
xpconnect \
$(NULL) $(NULL)
SHARED_LIBRARY_LIBS = \ SHARED_LIBRARY_LIBS = \

Просмотреть файл

@ -51,6 +51,8 @@
#include "nsTextFormatter.h" #include "nsTextFormatter.h"
#include "nsDirectoryServiceDefs.h" #include "nsDirectoryServiceDefs.h"
#include "nsCRT.h" #include "nsCRT.h"
#include "nsIConsoleService.h"
#include "nsIScriptError.h"
#define kExpatSeparatorChar 0xFFFF #define kExpatSeparatorChar 0xFFFF
@ -794,6 +796,19 @@ nsExpatDriver::HandleError(const char *aBuffer,
// Adjust the column number so that it is one based rather than zero based. // Adjust the column number so that it is one based rather than zero based.
PRInt32 colNumber = XML_GetCurrentColumnNumber(mExpatParser) + 1; PRInt32 colNumber = XML_GetCurrentColumnNumber(mExpatParser) + 1;
PRInt32 lineNumber = XML_GetCurrentLineNumber(mExpatParser);
nsCOMPtr<nsIConsoleService> cs
(do_GetService(NS_CONSOLESERVICE_CONTRACTID));
nsCOMPtr<nsIScriptError> serr(do_CreateInstance(NS_SCRIPTERROR_CONTRACTID));
if (serr && cs) {
if (NS_SUCCEEDED(serr->Init(description.get(),
mURISpec.get(),
sourceLine.get(),
lineNumber, colNumber,
nsIScriptError::errorFlag, "malformed-xml")))
cs->LogMessage(serr);
}
nsAutoString errorText; nsAutoString errorText;
CreateErrorText(description.get(), XML_GetBase(mExpatParser), CreateErrorText(description.get(), XML_GetBase(mExpatParser),
@ -1008,7 +1023,9 @@ nsExpatDriver::WillBuildModel(const CParserContext& aParserContext,
XML_SetParamEntityParsing(mExpatParser, XML_PARAM_ENTITY_PARSING_ALWAYS); XML_SetParamEntityParsing(mExpatParser, XML_PARAM_ENTITY_PARSING_ALWAYS);
#endif #endif
XML_SetBase(mExpatParser, aParserContext.mScanner->GetFilename().get()); mURISpec = aParserContext.mScanner->GetFilename();
XML_SetBase(mExpatParser, mURISpec.get());
// Set up the callbacks // Set up the callbacks
XML_SetXmlDeclHandler(mExpatParser, Driver_HandleXMLDeclaration); XML_SetXmlDeclHandler(mExpatParser, Driver_HandleXMLDeclaration);

Просмотреть файл

@ -111,6 +111,7 @@ private:
PRUint32 mBytesParsed; PRUint32 mBytesParsed;
nsCOMPtr<nsIExpatSink> mSink; nsCOMPtr<nsIExpatSink> mSink;
const nsCatalogData* mCatalogData; // weak const nsCatalogData* mCatalogData; // weak
nsString mURISpec;
}; };
nsresult NS_NewExpatDriver(nsIDTD** aDriver); nsresult NS_NewExpatDriver(nsIDTD** aDriver);