summaryrefslogtreecommitdiff
path: root/embeddedobj
diff options
context:
space:
mode:
authorMike Kaganski <mike.kaganski@collabora.com>2023-09-28 15:15:53 +0300
committerMike Kaganski <mike.kaganski@collabora.com>2023-09-28 16:02:55 +0200
commit11aa86140eaac3d1d67db1f337fc1c76a511778f (patch)
tree7809cae938a1dfb247c112216e2e45fcdbec9da0 /embeddedobj
parent608c35665bee5990bd7e2799854e233d1454b6a4 (diff)
Improve OleRun error reporting
1. Pass its error message up the call stack as the exception's message. 2. In case of REGDB_E_CLASSNOTREG, also obtain the object's class name and append it to the message. 3. Show this information in the message displayed for OLE activation error. This introduces a new SetExtendedMessage method in SfxErrorContext to store extra information for specific errors. Change-Id: Id3863276266d992ae407fbfa5568acf5c57aa96f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/157372 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'embeddedobj')
-rw-r--r--embeddedobj/source/msole/olecomponent.cxx24
1 files changed, 22 insertions, 2 deletions
diff --git a/embeddedobj/source/msole/olecomponent.cxx b/embeddedobj/source/msole/olecomponent.cxx
index fcd659e369a3..f981a4304656 100644
--- a/embeddedobj/source/msole/olecomponent.cxx
+++ b/embeddedobj/source/msole/olecomponent.cxx
@@ -24,6 +24,7 @@
#include <com/sun/star/lang/DisposedException.hpp>
#include <com/sun/star/embed/WrongStateException.hpp>
#include <com/sun/star/embed/UnreachableStateException.hpp>
+#include <com/sun/star/embed/EmbedStates.hpp>
#include <com/sun/star/ucb/XSimpleFileAccess.hpp>
#include <com/sun/star/beans/XPropertySet.hpp>
#include <com/sun/star/io/TempFile.hpp>
@@ -883,10 +884,29 @@ void OleComponent::RunObject()
if ( FAILED( hr ) )
{
+ OUString error = WindowsErrorStringFromHRESULT(hr);
if ( hr == REGDB_E_CLASSNOTREG )
- throw embed::UnreachableStateException(); // the object server is not installed
+ {
+ if (auto pOleObj
+ = m_pNativeImpl->m_pObj.QueryInterface<IOleObject>(sal::systools::COM_QUERY))
+ {
+ LPOLESTR lpUserType = nullptr;
+ if (SUCCEEDED(pOleObj->GetUserType(USERCLASSTYPE_FULL, &lpUserType)))
+ {
+ error += OUString::Concat("\n") + o3tl::toU(lpUserType);
+ sal::systools::COMReference<IMalloc> pMalloc;
+ hr = CoGetMalloc(1, &pMalloc); // if fails there will be a memory leak
+ SAL_WARN_IF(FAILED(hr) || !pMalloc, "embeddedobj.ole", "CoGetMalloc() failed");
+ if (pMalloc)
+ pMalloc->Free(lpUserType);
+ }
+ }
+ throw embed::UnreachableStateException(
+ error, getXWeak(), -1,
+ css::embed::EmbedStates::RUNNING); // the object server is not installed
+ }
else
- throw io::IOException();
+ throw io::IOException(error, getXWeak());
}
}
}