diff options
author | Max Kellermann <max@musicpd.org> | 2017-07-05 16:59:40 +0200 |
---|---|---|
committer | Max Kellermann <max@musicpd.org> | 2017-07-05 16:59:40 +0200 |
commit | 2db8cf477b8ef0e0517baf020b88ed3df73310aa (patch) | |
tree | 62b0f4c11062b4f63494cf3a5c7ea4b008fe91f9 /src/util | |
parent | 3cfefa53f72eeba7cf63d1ca8ba110108f85f52f (diff) |
util/Exception: add "fallback" and "separator" parameters
Diffstat (limited to 'src/util')
-rw-r--r-- | src/util/Exception.cxx | 12 | ||||
-rw-r--r-- | src/util/Exception.hxx | 6 |
2 files changed, 11 insertions, 7 deletions
diff --git a/src/util/Exception.cxx b/src/util/Exception.cxx index 2376f66cd..54f576212 100644 --- a/src/util/Exception.cxx +++ b/src/util/Exception.cxx @@ -1,5 +1,5 @@ /* - * Copyright (C) 2016 Max Kellermann <max.kellermann@gmail.com> + * Copyright (C) 2016-2017 Max Kellermann <max.kellermann@gmail.com> * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -32,7 +32,8 @@ #include <stdexcept> std::string -GetFullMessage(std::exception_ptr ep) noexcept +GetFullMessage(std::exception_ptr ep, + const char *fallback, const char *separator) noexcept { try { std::rethrow_exception(ep); @@ -41,10 +42,11 @@ GetFullMessage(std::exception_ptr ep) noexcept std::rethrow_if_nested(e); return e.what(); } catch (...) { - return std::string(e.what()) + "; " + - GetFullMessage(std::current_exception()); + return std::string(e.what()) + separator + + GetFullMessage(std::current_exception(), + fallback, separator); } } - return std::string("Unknown error"); + return fallback; } diff --git a/src/util/Exception.hxx b/src/util/Exception.hxx index 8e6941ea0..0ea24aa9b 100644 --- a/src/util/Exception.hxx +++ b/src/util/Exception.hxx @@ -1,5 +1,5 @@ /* - * Copyright (C) 2016 Max Kellermann <max.kellermann@gmail.com> + * Copyright (C) 2016-2017 Max Kellermann <max.kellermann@gmail.com> * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -38,6 +38,8 @@ * exceptions (if any). */ std::string -GetFullMessage(std::exception_ptr ep) noexcept; +GetFullMessage(std::exception_ptr ep, + const char *fallback="Unknown exception", + const char *separator="; ") noexcept; #endif |