mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-30 09:36:15 +02:00
debugger on autoCallFunction error
This commit is contained in:
parent
f32c687f03
commit
2dd61411af
2 changed files with 30 additions and 10 deletions
|
@ -79,24 +79,28 @@ ref<EvalState> EvalCommand::getEvalState()
|
||||||
return ref<EvalState>(evalState);
|
return ref<EvalState>(evalState);
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
EvalCommand::EvalCommand()
|
|
||||||
{
|
|
||||||
addFlag({
|
|
||||||
.longName = "debugger",
|
|
||||||
.description = "start an interactive environment if evaluation fails",
|
|
||||||
.handler = {&startReplOnEvalErrors, true},
|
|
||||||
});
|
|
||||||
}
|
|
||||||
// ref<EvalState> EvalCommand::getEvalState()
|
// ref<EvalState> EvalCommand::getEvalState()
|
||||||
// {
|
// {
|
||||||
// if (!evalState)
|
// if (!evalState)
|
||||||
// evalState = std::make_shared<EvalState>(searchPath, getStore());
|
// evalState = std::make_shared<EvalState>(searchPath, getStore());
|
||||||
// return ref<EvalState>(evalState);
|
// return ref<EvalState>(evalState);
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
|
||||||
|
EvalCommand::EvalCommand()
|
||||||
|
{
|
||||||
|
// std::cout << "EvalCommand::EvalCommand()" << std::endl;
|
||||||
|
addFlag({
|
||||||
|
.longName = "debugger",
|
||||||
|
.description = "start an interactive environment if evaluation fails",
|
||||||
|
.handler = {&startReplOnEvalErrors, true},
|
||||||
|
});
|
||||||
|
}
|
||||||
extern std::function<void(const Error & error, const std::map<std::string, Value *> & env)> debuggerHook;
|
extern std::function<void(const Error & error, const std::map<std::string, Value *> & env)> debuggerHook;
|
||||||
|
|
||||||
ref<EvalState> EvalCommand::getEvalState()
|
ref<EvalState> EvalCommand::getEvalState()
|
||||||
{
|
{
|
||||||
|
std::cout << " EvalCommand::getEvalState()" << startReplOnEvalErrors << std::endl;
|
||||||
if (!evalState) {
|
if (!evalState) {
|
||||||
evalState = std::make_shared<EvalState>(searchPath, getStore());
|
evalState = std::make_shared<EvalState>(searchPath, getStore());
|
||||||
if (startReplOnEvalErrors)
|
if (startReplOnEvalErrors)
|
||||||
|
|
|
@ -1398,12 +1398,28 @@ void EvalState::autoCallFunction(Bindings & args, Value & fun, Value & res)
|
||||||
if (j != args.end()) {
|
if (j != args.end()) {
|
||||||
actualArgs->attrs->push_back(*j);
|
actualArgs->attrs->push_back(*j);
|
||||||
} else if (!i.def) {
|
} else if (!i.def) {
|
||||||
throwMissingArgumentError(i.pos, R"(cannot evaluate a function that has an argument without a value ('%1%')
|
auto error = MissingArgumentError({
|
||||||
|
.msg = hintfmt(R"(cannot evaluate a function that has an argument without a value ('%1%')
|
||||||
|
|
||||||
Nix attempted to evaluate a function as a top level expression; in
|
Nix attempted to evaluate a function as a top level expression; in
|
||||||
this case it must have its arguments supplied either by default
|
this case it must have its arguments supplied either by default
|
||||||
values, or passed explicitly with '--arg' or '--argstr'. See
|
values, or passed explicitly with '--arg' or '--argstr'. See
|
||||||
https://nixos.org/manual/nix/stable/#ss-functions.)", i.name);
|
https://nixos.org/manual/nix/stable/#ss-functions.)", i.name),
|
||||||
|
.errPos = i.pos
|
||||||
|
});
|
||||||
|
|
||||||
|
// throwMissingArgumentError(i.pos
|
||||||
|
// , R"(cannot evaluate a function that has an argument without a value ('%1%')
|
||||||
|
|
||||||
|
// Nix attempted to evaluate a function as a top level expression; in
|
||||||
|
// this case it must have its arguments supplied either by default
|
||||||
|
// values, or passed explicitly with '--arg' or '--argstr'. See
|
||||||
|
// https://nixos.org/manual/nix/stable/#ss-functions.)", i.name);
|
||||||
|
|
||||||
|
if (debuggerHook)
|
||||||
|
debuggerHook(error, {{"fun", &fun}});
|
||||||
|
|
||||||
|
throw error;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue