summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMax Kellermann <max@musicpd.org>2019-05-22 18:24:45 +0200
committerMax Kellermann <max@musicpd.org>2020-07-06 21:07:16 +0200
commite5f23678ca1bdaaff3dba81af89d5d3fe9be594a (patch)
tree2fa172e34054b2b9742a9e136500d7d0c342477d
parent749ad7cd83f4061fc8714202bcc51b3ec065139d (diff)
Log: use GetFullMessage() to print exceptions
Print all nested exceptions on a single line to avoid confusion.
-rw-r--r--src/Log.cxx44
1 files changed, 6 insertions, 38 deletions
diff --git a/src/Log.cxx b/src/Log.cxx
index 622f79b69..6e47512c4 100644
--- a/src/Log.cxx
+++ b/src/Log.cxx
@@ -19,8 +19,7 @@
#include "LogV.hxx"
#include "util/Domain.hxx"
-
-#include <exception>
+#include "util/Exception.hxx"
#include <stdio.h>
#include <string.h>
@@ -94,31 +93,13 @@ FormatError(const Domain &domain, const char *fmt, ...) noexcept
void
LogError(const std::exception &e) noexcept
{
- Log(exception_domain, LogLevel::ERROR, e.what());
-
- try {
- std::rethrow_if_nested(e);
- } catch (const std::exception &nested) {
- LogError(nested, "nested");
- } catch (...) {
- Log(exception_domain, LogLevel::ERROR,
- "Unrecognized nested exception");
- }
+ LogError(exception_domain, GetFullMessage(e).c_str());
}
void
LogError(const std::exception &e, const char *msg) noexcept
{
- FormatError(exception_domain, "%s: %s", msg, e.what());
-
- try {
- std::rethrow_if_nested(e);
- } catch (const std::exception &nested) {
- LogError(nested);
- } catch (...) {
- Log(exception_domain, LogLevel::ERROR,
- "Unrecognized nested exception");
- }
+ FormatError(exception_domain, "%s: %s", msg, GetFullMessage(e).c_str());
}
void
@@ -136,27 +117,14 @@ FormatError(const std::exception &e, const char *fmt, ...) noexcept
void
LogError(const std::exception_ptr &ep) noexcept
{
- try {
- std::rethrow_exception(ep);
- } catch (const std::exception &e) {
- LogError(e);
- } catch (...) {
- Log(exception_domain, LogLevel::ERROR,
- "Unrecognized exception");
- }
+ LogError(exception_domain, GetFullMessage(ep).c_str());
}
void
LogError(const std::exception_ptr &ep, const char *msg) noexcept
{
- try {
- std::rethrow_exception(ep);
- } catch (const std::exception &e) {
- LogError(e, msg);
- } catch (...) {
- FormatError(exception_domain,
- "%s: Unrecognized exception", msg);
- }
+ FormatError(exception_domain, "%s: %s", msg,
+ GetFullMessage(ep).c_str());
}
void