mirror of
https://github.com/NixOS/nix
synced 2025-06-27 12:41:15 +02:00
template-ize debugThrow
This commit is contained in:
parent
2c9fafdc9e
commit
1ea13084c9
2 changed files with 22 additions and 26 deletions
|
@ -128,10 +128,30 @@ public:
|
|||
bool debugQuit;
|
||||
std::list<DebugTrace> debugTraces;
|
||||
|
||||
template<class E>
|
||||
[[gnu::noinline, gnu::noreturn]]
|
||||
void debugThrow(const Error &error, const Env & env, const Expr & expr) const;
|
||||
void debugThrow(const E &error, const Env & env, const Expr & expr) const
|
||||
{
|
||||
if (debuggerHook)
|
||||
debuggerHook(&error, env, expr);
|
||||
|
||||
throw error;
|
||||
}
|
||||
|
||||
template<class E>
|
||||
[[gnu::noinline, gnu::noreturn]]
|
||||
void debugThrowLastTrace(Error & e) const;
|
||||
void debugThrowLastTrace(E & e) const
|
||||
{
|
||||
// Call this in the situation where Expr and Env are inaccessible.
|
||||
// The debugger will start in the last context that's in the
|
||||
// DebugTrace stack.
|
||||
if (debuggerHook && !debugTraces.empty()) {
|
||||
const DebugTrace & last = debugTraces.front();
|
||||
debuggerHook(&e, last.env, last.expr);
|
||||
}
|
||||
|
||||
throw e;
|
||||
}
|
||||
|
||||
private:
|
||||
SrcToStore srcToStore;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue