mirror of https://github.com/KLayout/klayout.git
Avoid some more exceptions in XML handler
This commit is contained in:
parent
739cdfc1d5
commit
4277d0d8d5
|
|
@ -394,12 +394,13 @@ class SAXHandler
|
||||||
public:
|
public:
|
||||||
SAXHandler (XMLStructureHandler *sh);
|
SAXHandler (XMLStructureHandler *sh);
|
||||||
|
|
||||||
bool characters (const QString &ch);
|
virtual bool characters (const QString &ch);
|
||||||
bool endElement (const QString &namespaceURI, const QString &localName, const QString &qName);
|
virtual bool endElement (const QString &namespaceURI, const QString &localName, const QString &qName);
|
||||||
bool startElement (const QString &namespaceURI, const QString &localName, const QString &qName, const QXmlAttributes &atts);
|
virtual bool startElement (const QString &namespaceURI, const QString &localName, const QString &qName, const QXmlAttributes &atts);
|
||||||
bool error (const QXmlParseException &exception);
|
virtual bool error (const QXmlParseException &exception);
|
||||||
bool fatalError (const QXmlParseException &exception);
|
virtual bool fatalError (const QXmlParseException &exception);
|
||||||
bool warning (const QXmlParseException &exception);
|
virtual bool warning (const QXmlParseException &exception);
|
||||||
|
virtual QString errorString () const;
|
||||||
|
|
||||||
void setDocumentLocator (QXmlLocator *locator);
|
void setDocumentLocator (QXmlLocator *locator);
|
||||||
|
|
||||||
|
|
@ -412,6 +413,7 @@ private:
|
||||||
QXmlLocator *mp_locator;
|
QXmlLocator *mp_locator;
|
||||||
XMLStructureHandler *mp_struct_handler;
|
XMLStructureHandler *mp_struct_handler;
|
||||||
std::unique_ptr<tl::XMLLocatedException> m_error;
|
std::unique_ptr<tl::XMLLocatedException> m_error;
|
||||||
|
std::string m_error_string;
|
||||||
};
|
};
|
||||||
|
|
||||||
// --------------------------------------------------------------------------------------------------------
|
// --------------------------------------------------------------------------------------------------------
|
||||||
|
|
@ -439,9 +441,11 @@ SAXHandler::startElement (const QString &qs_uri, const QString &qs_lname, const
|
||||||
try {
|
try {
|
||||||
mp_struct_handler->start_element (uri, lname, qname);
|
mp_struct_handler->start_element (uri, lname, qname);
|
||||||
} catch (tl::XMLException &ex) {
|
} catch (tl::XMLException &ex) {
|
||||||
throw tl::XMLLocatedException (ex.raw_msg (), mp_locator->lineNumber (), mp_locator->columnNumber ());
|
m_error_string = ex.raw_msg ();
|
||||||
|
return false;
|
||||||
} catch (tl::Exception &ex) {
|
} catch (tl::Exception &ex) {
|
||||||
throw tl::XMLLocatedException (ex.msg (), mp_locator->lineNumber (), mp_locator->columnNumber ());
|
m_error_string = ex.msg ();
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// successful
|
// successful
|
||||||
|
|
@ -458,9 +462,11 @@ SAXHandler::endElement (const QString &qs_uri, const QString &qs_lname, const QS
|
||||||
try {
|
try {
|
||||||
mp_struct_handler->end_element (uri, lname, qname);
|
mp_struct_handler->end_element (uri, lname, qname);
|
||||||
} catch (tl::XMLException &ex) {
|
} catch (tl::XMLException &ex) {
|
||||||
throw tl::XMLLocatedException (ex.raw_msg (), mp_locator->lineNumber (), mp_locator->columnNumber ());
|
m_error_string = ex.raw_msg ();
|
||||||
|
return false;
|
||||||
} catch (tl::Exception &ex) {
|
} catch (tl::Exception &ex) {
|
||||||
throw tl::XMLLocatedException (ex.msg (), mp_locator->lineNumber (), mp_locator->columnNumber ());
|
m_error_string = ex.msg ();
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// successful
|
// successful
|
||||||
|
|
@ -473,15 +479,24 @@ SAXHandler::characters (const QString &t)
|
||||||
try {
|
try {
|
||||||
mp_struct_handler->characters (tl::to_string (t));
|
mp_struct_handler->characters (tl::to_string (t));
|
||||||
} catch (tl::XMLException &ex) {
|
} catch (tl::XMLException &ex) {
|
||||||
throw tl::XMLLocatedException (ex.raw_msg (), mp_locator->lineNumber (), mp_locator->columnNumber ());
|
m_error_string = ex.raw_msg ();
|
||||||
|
return false;
|
||||||
} catch (tl::Exception &ex) {
|
} catch (tl::Exception &ex) {
|
||||||
throw tl::XMLLocatedException (ex.msg (), mp_locator->lineNumber (), mp_locator->columnNumber ());
|
m_error_string = ex.msg ();
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// successful
|
// successful
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString
|
||||||
|
SAXHandler::errorString () const
|
||||||
|
{
|
||||||
|
return tl::to_qstring (m_error_string);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
SAXHandler::error (const QXmlParseException &ex)
|
SAXHandler::error (const QXmlParseException &ex)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue