mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-26 15:56:18 +02:00
print message with exceptions in a try clause
This commit is contained in:
parent
9151dbff88
commit
bc0d41e9ba
3 changed files with 22 additions and 6 deletions
|
@ -464,10 +464,11 @@ EvalState::EvalState(
|
|||
, emptyBindings(0)
|
||||
, store(store)
|
||||
, buildStore(buildStore ? buildStore : store)
|
||||
, debugRepl(0)
|
||||
, debugRepl(nullptr)
|
||||
, debugStop(false)
|
||||
, debugQuit(false)
|
||||
, ignoreTry(false)
|
||||
, trylevel(0)
|
||||
, regexCache(makeRegexCache())
|
||||
#if HAVE_BOEHMGC
|
||||
, valueAllocCache(std::allocate_shared<void *>(traceable_allocator<void *>(), nullptr))
|
||||
|
@ -833,7 +834,14 @@ void EvalState::runDebugRepl(const Error * error, const Env & env, const Expr &
|
|||
: nullptr;
|
||||
|
||||
if (error)
|
||||
printError("%s\n\n" ANSI_BOLD "Starting REPL to allow you to inspect the current state of the evaluator.\n" ANSI_NORMAL, error->what());
|
||||
{
|
||||
printError("%s\n\n", error->what());
|
||||
|
||||
if (trylevel > 0 && error->info().level != lvlInfo)
|
||||
printError("This exception occurred in a try clause. use " ANSI_GREEN "--ignore-try" ANSI_NORMAL " to skip these.\n");
|
||||
|
||||
printError(ANSI_BOLD "Starting REPL to allow you to inspect the current state of the evaluator.\n" ANSI_NORMAL, error->what());
|
||||
}
|
||||
|
||||
auto se = getStaticEnv(expr);
|
||||
if (se) {
|
||||
|
|
|
@ -131,6 +131,7 @@ public:
|
|||
bool debugStop;
|
||||
bool debugQuit;
|
||||
bool ignoreTry;
|
||||
int trylevel;
|
||||
std::list<DebugTrace> debugTraces;
|
||||
std::map<const Expr*, const std::shared_ptr<const StaticEnv>> exprEnvs;
|
||||
const std::shared_ptr<const StaticEnv> getStaticEnv(const Expr & expr) const
|
||||
|
|
|
@ -853,11 +853,15 @@ static void prim_tryEval(EvalState & state, const PosIdx pos, Value * * args, Va
|
|||
auto attrs = state.buildBindings(2);
|
||||
|
||||
void (* savedDebugRepl)(ref<EvalState> es, const ValMap & extraEnv) = nullptr;
|
||||
if (state.debugRepl && state.ignoreTry)
|
||||
if (state.debugRepl)
|
||||
{
|
||||
// to prevent starting the repl from exceptions withing a tryEval, null it.
|
||||
savedDebugRepl = state.debugRepl;
|
||||
state.debugRepl = nullptr;
|
||||
state.trylevel++;
|
||||
if (state.ignoreTry)
|
||||
{
|
||||
// to prevent starting the repl from exceptions withing a tryEval, null it.
|
||||
savedDebugRepl = state.debugRepl;
|
||||
state.debugRepl = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
|
@ -873,6 +877,9 @@ static void prim_tryEval(EvalState & state, const PosIdx pos, Value * * args, Va
|
|||
if (savedDebugRepl)
|
||||
state.debugRepl = savedDebugRepl;
|
||||
|
||||
if (state.debugRepl)
|
||||
state.trylevel--;
|
||||
|
||||
v.mkAttrs(attrs);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue