mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-26 07:46:21 +02:00
Add EvalErrorBuilder::panic()
An nicer alternative to printError + abort, or assert(false /* foo */)
This commit is contained in:
parent
13522229a9
commit
61577402ba
2 changed files with 14 additions and 0 deletions
|
@ -92,6 +92,14 @@ void EvalErrorBuilder<T>::debugThrow()
|
||||||
throw error;
|
throw error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<class T>
|
||||||
|
void EvalErrorBuilder<T>::panic()
|
||||||
|
{
|
||||||
|
logError(error.info());
|
||||||
|
printError("This is a bug! An unexpected condition occurred, causing the Nix evaluator to have to stop. If you could share a reproducible example or a core dump, please open an issue at https://github.com/NixOS/nix/issues");
|
||||||
|
abort();
|
||||||
|
}
|
||||||
|
|
||||||
template class EvalErrorBuilder<EvalBaseError>;
|
template class EvalErrorBuilder<EvalBaseError>;
|
||||||
template class EvalErrorBuilder<EvalError>;
|
template class EvalErrorBuilder<EvalError>;
|
||||||
template class EvalErrorBuilder<AssertionError>;
|
template class EvalErrorBuilder<AssertionError>;
|
||||||
|
|
|
@ -112,6 +112,12 @@ public:
|
||||||
* Delete the `EvalErrorBuilder` and throw the underlying exception.
|
* Delete the `EvalErrorBuilder` and throw the underlying exception.
|
||||||
*/
|
*/
|
||||||
[[gnu::noinline, gnu::noreturn]] void debugThrow();
|
[[gnu::noinline, gnu::noreturn]] void debugThrow();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A programming error or fatal condition occurred. Abort the process for core dump and debugging.
|
||||||
|
* This does not print a proper backtrace, because unwinding the stack is destructive.
|
||||||
|
*/
|
||||||
|
[[gnu::noinline, gnu::noreturn]] void panic();
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue