mirror of
https://github.com/latentPrion/libspinscale.git
synced 2026-06-23 19:48:32 +00:00
Printing: print fewer blank newlines
This commit is contained in:
@@ -74,6 +74,29 @@ auto asAwaiter(T &t) noexcept(noexcept(get_operator_co_await(t)))
|
|||||||
return get_operator_co_await(t);
|
return get_operator_co_await(t);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline bool endsWithLineBreak(const std::string &message)
|
||||||
|
{
|
||||||
|
return !message.empty()
|
||||||
|
&& (message.back() == '\n' || message.back() == '\r');
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void appendGroupAdapterExceptionLine(
|
||||||
|
std::ostringstream &ostream, std::exception_ptr exceptionPtr)
|
||||||
|
{
|
||||||
|
ostream << "Exc thrown in Group Adapter: ";
|
||||||
|
try {
|
||||||
|
std::rethrow_exception(exceptionPtr);
|
||||||
|
} catch (const std::exception &e) {
|
||||||
|
const std::string message = e.what();
|
||||||
|
ostream << message;
|
||||||
|
if (!endsWithLineBreak(message)) {
|
||||||
|
ostream << "\n";
|
||||||
|
}
|
||||||
|
} catch (...) {
|
||||||
|
ostream << "<unknown exception type>\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace detail
|
} // namespace detail
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
@@ -225,15 +248,8 @@ struct Group
|
|||||||
}
|
}
|
||||||
|
|
||||||
doThrow = true;
|
doThrow = true;
|
||||||
ostream << "Exc thrown in Group Adapter: ";
|
detail::appendGroupAdapterExceptionLine(
|
||||||
try {
|
ostream, item.adapterException);
|
||||||
std::rethrow_exception(item.adapterException);
|
|
||||||
} catch (const std::exception &e) {
|
|
||||||
ostream << e.what();
|
|
||||||
} catch (...) {
|
|
||||||
ostream << "<unknown exception type>";
|
|
||||||
}
|
|
||||||
ostream << "\n";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (doThrow) {
|
if (doThrow) {
|
||||||
@@ -578,15 +594,8 @@ struct Group
|
|||||||
assert(item.calleeException);
|
assert(item.calleeException);
|
||||||
|
|
||||||
hasFailures = true;
|
hasFailures = true;
|
||||||
ostream << "Exc thrown in Group Adapter: ";
|
detail::appendGroupAdapterExceptionLine(
|
||||||
try {
|
ostream, item.calleeException);
|
||||||
std::rethrow_exception(item.calleeException);
|
|
||||||
} catch (const std::exception &e) {
|
|
||||||
ostream << e.what();
|
|
||||||
} catch (...) {
|
|
||||||
ostream << "<unknown exception type>";
|
|
||||||
}
|
|
||||||
ostream << "\n";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!hasFailures) {
|
if (!hasFailures) {
|
||||||
|
|||||||
Reference in New Issue
Block a user