fix(util/script_exception): make sure a script_nested_exception may have a nested script_nested_exception, use LEAN_THREAD_LOCAL macro instead of thread_local
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
This commit is contained in:
parent
24452289dd
commit
f101554e93
1 changed files with 11 additions and 6 deletions
|
@ -7,6 +7,7 @@ Author: Leonardo de Moura
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
|
#include "util/thread.h"
|
||||||
#include "util/debug.h"
|
#include "util/debug.h"
|
||||||
#include "util/script_exception.h"
|
#include "util/script_exception.h"
|
||||||
|
|
||||||
|
@ -70,7 +71,7 @@ char const * script_exception::get_msg() const noexcept {
|
||||||
}
|
}
|
||||||
|
|
||||||
char const * script_exception::what() const noexcept {
|
char const * script_exception::what() const noexcept {
|
||||||
static thread_local std::string buffer;
|
static LEAN_THREAD_LOCAL std::string buffer;
|
||||||
std::ostringstream strm;
|
std::ostringstream strm;
|
||||||
char const * msg = get_msg();
|
char const * msg = get_msg();
|
||||||
char const * space = msg && *msg == ' ' ? "" : " ";
|
char const * space = msg && *msg == ' ' ? "" : " ";
|
||||||
|
@ -92,10 +93,14 @@ script_nested_exception::script_nested_exception(source s, std::string f, unsign
|
||||||
script_nested_exception::~script_nested_exception() {}
|
script_nested_exception::~script_nested_exception() {}
|
||||||
|
|
||||||
char const * script_nested_exception::what() const noexcept {
|
char const * script_nested_exception::what() const noexcept {
|
||||||
static thread_local std::string buffer;
|
std::string super_what = script_exception::what();
|
||||||
|
std::string nested_what = get_exception().what();
|
||||||
|
{
|
||||||
|
static LEAN_THREAD_LOCAL std::string buffer;
|
||||||
std::ostringstream strm;
|
std::ostringstream strm;
|
||||||
strm << script_exception::what() << "\n" << get_exception().what();
|
strm << super_what << "\n" << nested_what;
|
||||||
buffer = strm.str();
|
buffer = strm.str();
|
||||||
return buffer.c_str();
|
return buffer.c_str();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue