summaryrefslogtreecommitdiff
path: root/sax/source
diff options
context:
space:
mode:
authorMike Kaganski <mike.kaganski@collabora.com>2023-10-12 22:02:15 +0300
committerMike Kaganski <mike.kaganski@collabora.com>2023-10-14 15:37:17 +0200
commit176e8cf09a527438ec9b2b20ba2df23fa45226bc (patch)
tree76897d74143771a9ee9249c49bbe91da9ffa0433 /sax/source
parent328d6aae9e2b7a73f6672800629230f5b46d15b1 (diff)
Use exception ctors, instead of setting members later
Avoids overwriting source location in message Change-Id: Ia0290c7dd1ab3ea1357712a27ecab75c7b583dd4 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/157893 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'sax/source')
-rw-r--r--sax/source/expatwrap/saxwriter.cxx45
1 files changed, 12 insertions, 33 deletions
diff --git a/sax/source/expatwrap/saxwriter.cxx b/sax/source/expatwrap/saxwriter.cxx
index 180126684ea1..55608101faf5 100644
--- a/sax/source/expatwrap/saxwriter.cxx
+++ b/sax/source/expatwrap/saxwriter.cxx
@@ -1158,15 +1158,11 @@ void SAXWriter::startElement(const OUString& aName, const Reference<XAttributeLi
{
if (!m_bDocStarted)
{
- SAXException except;
- except.Message = "startElement called before startDocument";
- throw except;
+ throw SAXException("startElement called before startDocument", {}, {});
}
if (m_bIsCDATA)
{
- SAXException except;
- except.Message = "startElement call not allowed with CDATA sections";
- throw except;
+ throw SAXException("startElement call not allowed with CDATA sections", {}, {});
}
sal_Int32 nLength(0);
@@ -1210,15 +1206,12 @@ void SAXWriter::startElement(const OUString& aName, const Reference<XAttributeLi
if (eRet == SAX_WARNING)
{
- SAXInvalidCharacterException except;
- except.Message = "Invalid character during XML-Export in an attribute value";
- throw except;
+ throw SAXInvalidCharacterException(
+ "Invalid character during XML-Export in an attribute value", {}, {});
}
else if (eRet == SAX_ERROR)
{
- SAXException except;
- except.Message = "Invalid character during XML-Export";
- throw except;
+ throw SAXException("Invalid character during XML-Export", {}, {});
}
}
@@ -1262,9 +1255,7 @@ void SAXWriter::endElement(const OUString& aName)
if (!bRet)
{
- SAXException except;
- except.Message = "Invalid character during XML-Export";
- throw except;
+ throw SAXException("Invalid character during XML-Export", {}, {});
}
}
@@ -1272,9 +1263,7 @@ void SAXWriter::characters(const OUString& aChars)
{
if (!m_bDocStarted)
{
- SAXException except;
- except.Message = "characters method called before startDocument";
- throw except;
+ throw SAXException("characters method called before startDocument", {}, {});
}
bool bThrowException(false);
@@ -1314,9 +1303,7 @@ void SAXWriter::characters(const OUString& aChars)
}
if (bThrowException)
{
- SAXInvalidCharacterException except;
- except.Message = "Invalid character during XML-Export";
- throw except;
+ throw SAXInvalidCharacterException("Invalid character during XML-Export", {}, {});
}
}
@@ -1357,9 +1344,7 @@ void SAXWriter::processingInstruction(const OUString& aTarget, const OUString& a
if (!m_pSaxWriterHelper->processingInstruction(aTarget, aData))
{
- SAXException except;
- except.Message = "Invalid character during XML-Export";
- throw except;
+ throw SAXException("Invalid character during XML-Export", {}, {});
}
}
@@ -1391,9 +1376,7 @@ void SAXWriter::endCDATA()
{
if (!m_bDocStarted || !m_bIsCDATA)
{
- SAXException except;
- except.Message = "endCDATA was called without startCDATA";
- throw except;
+ throw SAXException("endCDATA was called without startCDATA", {}, {});
}
sal_Int32 nPrefix = getIndentPrefixLength(3);
@@ -1427,9 +1410,7 @@ void SAXWriter::comment(const OUString& sComment)
if (!m_pSaxWriterHelper->comment(sComment))
{
- SAXException except;
- except.Message = "Invalid character during XML-Export";
- throw except;
+ throw SAXException("Invalid character during XML-Export", {}, {});
}
}
@@ -1467,9 +1448,7 @@ void SAXWriter::unknown(const OUString& sString)
if (!m_pSaxWriterHelper->writeString(sString, false, false))
{
- SAXException except;
- except.Message = "Invalid character during XML-Export";
- throw except;
+ throw SAXException("Invalid character during XML-Export", {}, {});
}
}