summaryrefslogtreecommitdiff
path: root/svtools/source/misc/ehdl.cxx
diff options
context:
space:
mode:
authorNoel Grandin <noelgrandin@gmail.com>2023-09-30 20:47:46 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2023-10-03 10:12:41 +0200
commitd9e322d60f65ff20631dab87baa5a2c7c71daaa2 (patch)
treed481e5a4728363b3866b5b5f6dbe64a2780b04a6 /svtools/source/misc/ehdl.cxx
parent64fc701388d1dcf8ae36ba2cc73eb5416a7c3374 (diff)
replace ErrorInfo with simpler mechanism
Instead of returning ErrCode class everywhere, return a new class ErrrCodeMsg, which combines an ErrCode with the other parameters that are used to control the error reporting. I do not change everything that uses ErrCode here, I started from SfxBaseController/SfxMedium and worked outwards. This change serves two purposes (1) Replace the extremely whacky ErrorInfo mechanism we were using to smuggle information into the error handler reporting mechanism with a very straightforward approach of just combining it into the error class. (2) Allow us to capture the source location that produced the error, which makes debugging the source of a problem soooo much easier. Change-Id: I978b8f00c9851b41a216c7ebdef2ef94251d5519 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/157440 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'svtools/source/misc/ehdl.cxx')
-rw-r--r--svtools/source/misc/ehdl.cxx32
1 files changed, 11 insertions, 21 deletions
diff --git a/svtools/source/misc/ehdl.cxx b/svtools/source/misc/ehdl.cxx
index ef35b3975fca..ab602be60aaf 100644
--- a/svtools/source/misc/ehdl.cxx
+++ b/svtools/source/misc/ehdl.cxx
@@ -151,7 +151,7 @@ SfxErrorHandler::~SfxErrorHandler()
{
}
-bool SfxErrorHandler::CreateString(const ErrorInfo *pErr, OUString &rStr) const
+bool SfxErrorHandler::CreateString(const ErrCodeMsg& nErr, OUString &rStr) const
/* [Description]
@@ -160,25 +160,15 @@ bool SfxErrorHandler::CreateString(const ErrorInfo *pErr, OUString &rStr) const
*/
{
- ErrCode nErrCode(sal_uInt32(pErr->GetErrorCode()) & ERRCODE_ERROR_MASK);
- if (pErr->GetErrorCode().GetArea() < lStart || lEnd < pErr->GetErrorCode().GetArea())
+ ErrCode nErrCode(sal_uInt32(nErr.GetCode()) & ERRCODE_ERROR_MASK);
+ if (nErr.GetCode().GetArea() < lStart || lEnd < nErr.GetCode().GetArea())
return false;
if(GetErrorString(nErrCode, rStr))
{
- const StringErrorInfo *pStringInfo = dynamic_cast<const StringErrorInfo *>(pErr);
- if(pStringInfo)
- {
- rStr = rStr.replaceAll("$(ARG1)", pStringInfo->GetErrorString());
- }
- else
- {
- const TwoStringErrorInfo * pTwoStringInfo = dynamic_cast<const TwoStringErrorInfo* >(pErr);
- if (pTwoStringInfo)
- {
- rStr = rStr.replaceAll("$(ARG1)", pTwoStringInfo->GetArg1());
- rStr = rStr.replaceAll("$(ARG2)", pTwoStringInfo->GetArg2());
- }
- }
+ if(!nErr.GetArg1().isEmpty())
+ rStr = rStr.replaceAll("$(ARG1)", nErr.GetArg1());
+ if(!nErr.GetArg2().isEmpty())
+ rStr = rStr.replaceAll("$(ARG2)", nErr.GetArg2());
return true;
}
return false;
@@ -219,7 +209,7 @@ bool SfxErrorHandler::GetErrorString(ErrCode lErrId, OUString &rStr) const
for (const ErrMsgCode* pItem = pIds; pItem->second; ++pItem)
{
- if (pItem->second.StripWarningAndDynamic() == lErrId.StripWarningAndDynamic())
+ if (pItem->second.StripWarning() == lErrId.StripWarning())
{
rStr = rStr.replaceAll("$(ERROR)", Translate::get(pItem->first, aResLocale));
bRet = true;
@@ -258,7 +248,7 @@ SfxErrorContext::SfxErrorContext(
pIds = RID_ERRCTX;
}
-bool SfxErrorContext::GetString(ErrCode nErrId, OUString &rStr)
+bool SfxErrorContext::GetString(const ErrCodeMsg& nErr, OUString &rStr)
/* [Description]
@@ -282,7 +272,7 @@ bool SfxErrorContext::GetString(ErrCode nErrId, OUString &rStr)
if ( bRet )
{
- sal_uInt16 nId = nErrId.IsWarning() ? ERRCTX_WARNING : ERRCTX_ERROR;
+ sal_uInt16 nId = nErr.IsWarning() ? ERRCTX_WARNING : ERRCTX_ERROR;
for (const ErrMsgCode* pItem = RID_ERRCTX; pItem->second; ++pItem)
{
if (sal_uInt32(pItem->second) == nId)
@@ -294,7 +284,7 @@ bool SfxErrorContext::GetString(ErrCode nErrId, OUString &rStr)
}
if (bRet)
- if (auto it = m_extMessages.find(sal_uInt32(nErrId)); it != m_extMessages.end())
+ if (auto it = m_extMessages.find(sal_uInt32(nErr.GetCode())); it != m_extMessages.end())
rStr += "\n" + it->second;
return bRet;