From 7d205330dbf1c2fd44d9d58393ab46434ac8bb5e Mon Sep 17 00:00:00 2001 From: Kae <80987908+Novaenia@users.noreply.github.com> Date: Sun, 25 Jun 2023 18:12:54 +1000 Subject: More directives optimization --- source/core/StarException_windows.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'source/core/StarException_windows.cpp') diff --git a/source/core/StarException_windows.cpp b/source/core/StarException_windows.cpp index 8892eb2..ca81332 100644 --- a/source/core/StarException_windows.cpp +++ b/source/core/StarException_windows.cpp @@ -145,7 +145,7 @@ StarException::StarException() noexcept : StarException(std::string("StarExcepti StarException::~StarException() noexcept {} -StarException::StarException(std::string message) noexcept : StarException("StarException", move(message)) {} +StarException::StarException(std::string message, bool genStackTrace) noexcept : StarException("StarException", move(message), genStackTrace) {} StarException::StarException(std::exception const& cause) noexcept : StarException("StarException", std::string(), cause) {} @@ -162,20 +162,20 @@ const char* StarException::what() const throw() { return m_whatBuffer.c_str(); } -StarException::StarException(char const* type, std::string message) noexcept { +StarException::StarException(char const* type, std::string message, bool genStackTrace) noexcept { auto printException = []( - std::ostream& os, bool fullStacktrace, char const* type, std::string message, StackCapture stack) { + std::ostream& os, bool fullStacktrace, char const* type, std::string message, Maybe stack) { os << "(" << type << ")"; if (!message.empty()) os << " " << message; - if (fullStacktrace) { + if (fullStacktrace && stack) { os << std::endl; - os << outputStack(stack); + os << outputStack(*stack); } }; - m_printException = bind(printException, _1, _2, type, move(message), captureStack()); + m_printException = bind(printException, _1, _2, type, move(message), genStackTrace ? captureStack() : Maybe()); } StarException::StarException(char const* type, std::string message, std::exception const& cause) noexcept -- cgit v1.2.3