comphelper/source/misc/diagnose_ex.cxx | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-)
New commits: commit 2d5894cc9b2374db9b5d2335db2d3566513fe062 Author: Noel Grandin <noel.gran...@collabora.co.uk> AuthorDate: Fri Nov 10 10:52:11 2023 +0200 Commit: Noel Grandin <noel.gran...@collabora.co.uk> CommitDate: Fri Nov 10 13:51:00 2023 +0100 avoid unnecessary intermediate buffer and make it more obvious that we are doing recursive stuff here Change-Id: I00209e0123eaacb015484949700ea0c983278fbb Reviewed-on: https://gerrit.libreoffice.org/c/core/+/159285 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> diff --git a/comphelper/source/misc/diagnose_ex.cxx b/comphelper/source/misc/diagnose_ex.cxx index ec00bd0e1436..487f98b637a0 100644 --- a/comphelper/source/misc/diagnose_ex.cxx +++ b/comphelper/source/misc/diagnose_ex.cxx @@ -117,7 +117,7 @@ static void exceptionToStringImpl(OStringBuffer& sMessage, const css::uno::Any & if ( caught >>= specialized ) { sMessage.append("\n wrapped: "); - sMessage.append(exceptionToString(specialized.ErrorDetails)); + exceptionToStringImpl(sMessage, specialized.ErrorDetails); } } { @@ -125,7 +125,7 @@ static void exceptionToStringImpl(OStringBuffer& sMessage, const css::uno::Any & if ( caught >>= specialized ) { sMessage.append("\n wrapped: "); - sMessage.append(exceptionToString(specialized.BackendException)); + exceptionToStringImpl(sMessage, specialized.BackendException); } } { @@ -141,7 +141,7 @@ static void exceptionToStringImpl(OStringBuffer& sMessage, const css::uno::Any & if ( caught >>= specialized ) { sMessage.append("\n wrapped: "); - sMessage.append(exceptionToString(specialized.Cause)); + exceptionToStringImpl(sMessage, specialized.Cause); } } { @@ -173,7 +173,7 @@ static void exceptionToStringImpl(OStringBuffer& sMessage, const css::uno::Any & if ( caught >>= specialized ) { sMessage.append("\n wrapped: "); - sMessage.append(exceptionToString(specialized.TargetException)); + exceptionToStringImpl(sMessage, specialized.TargetException); } } { @@ -181,7 +181,7 @@ static void exceptionToStringImpl(OStringBuffer& sMessage, const css::uno::Any & if ( caught >>= specialized ) { sMessage.append("\n wrapped: "); - sMessage.append(exceptionToString(specialized.TargetException)); + exceptionToStringImpl(sMessage, specialized.TargetException); } } { @@ -255,7 +255,7 @@ static void exceptionToStringImpl(OStringBuffer& sMessage, const css::uno::Any & sMessage.append(" ErrorCode: "); sMessage.append(specialized.ErrorCode); sMessage.append("\n wrapped: "); - sMessage.append(exceptionToString(specialized.NextException)); + exceptionToStringImpl(sMessage, specialized.NextException); } } { @@ -279,7 +279,7 @@ static void exceptionToStringImpl(OStringBuffer& sMessage, const css::uno::Any & if ( caught >>= specialized ) { sMessage.append("\n Reason: "); - sMessage.append(exceptionToString( specialized.Reason )); + exceptionToStringImpl( sMessage, specialized.Reason ); } } { @@ -335,7 +335,7 @@ static void exceptionToStringImpl(OStringBuffer& sMessage, const css::uno::Any & if ( caught >>= specialized ) { sMessage.append("\n wrapped: "); - sMessage.append(exceptionToString( specialized.WrappedException )); + exceptionToStringImpl( sMessage, specialized.WrappedException ); } } { commit 1041dc7d41e848e1690c67009a5add2eeeaf698b Author: Noel Grandin <noel.gran...@collabora.co.uk> AuthorDate: Fri Nov 10 10:46:51 2023 +0200 Commit: Noel Grandin <noel.gran...@collabora.co.uk> CommitDate: Fri Nov 10 13:50:51 2023 +0100 reduce noise in exceptionToStringImpl otherwise we end up with log messages like wrapped: void message: "at C:/cygwin/home/tdf/lode/jenkins/workspace/gerrit_windows/comphelper/source/misc/diagnose_ex.cxx:66" when we call ourself to print out sub-exceptions Change-Id: I9e598a6b68469e9baa3232811f310b7e24f1b77e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/159284 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> diff --git a/comphelper/source/misc/diagnose_ex.cxx b/comphelper/source/misc/diagnose_ex.cxx index e805c5b4c2a5..ec00bd0e1436 100644 --- a/comphelper/source/misc/diagnose_ex.cxx +++ b/comphelper/source/misc/diagnose_ex.cxx @@ -62,6 +62,9 @@ static void exceptionToStringImpl(OStringBuffer& sMessage, const css::uno::Any & auto toOString = [](OUString const & s) { return OUStringToOString( s, osl_getThreadTextEncoding() ); }; + // when called recursively, we might not have any exception to print + if (!caught.hasValue()) + return; sMessage.append(toOString(caught.getValueTypeName())); css::uno::Exception exception; caught >>= exception;