Discuss re-entrant errors and design
This commit is contained in:
parent
ca7c5e08c1
commit
6228b6b950
2 changed files with 18 additions and 0 deletions
|
@ -203,6 +203,9 @@ public:
|
|||
throw std::move(error);
|
||||
}
|
||||
|
||||
// This is dangerous, but gets in line with the idea that error creation and
|
||||
// throwing should not allocate on the stack of hot functions.
|
||||
// as long as errors are immediately thrown, it works.
|
||||
ErrorBuilder * errorBuilder;
|
||||
|
||||
template<typename... Args>
|
||||
|
|
|
@ -45,6 +45,21 @@ namespace nix {
|
|||
);
|
||||
}
|
||||
|
||||
TEST_F(ErrorTraceTest, NestedThrows) {
|
||||
try {
|
||||
state.error("Not much").withTrace(noPos, "No more").debugThrow<EvalError>();
|
||||
} catch (BaseError & e) {
|
||||
try {
|
||||
state.error("Not much more").debugThrow<EvalError>();
|
||||
} catch (Error & e2) {
|
||||
e.addTrace(state.positions[noPos], "Something", "");
|
||||
//e2.addTrace(state.positions[noPos], "Something", "");
|
||||
ASSERT_TRUE(e.info().traces.size() == 2);
|
||||
ASSERT_TRUE(e2.info().traces.size() == 0);
|
||||
ASSERT_FALSE(&e.info() == &e2.info());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#define ASSERT_TRACE1(args, type, message) \
|
||||
ASSERT_THROW( \
|
||||
|
|
Loading…
Reference in a new issue