mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-22 22:16:16 +02:00
builtins.warn: Use logWarning
Constructing ErrorInfo is a little awkward for now, but this does produce a richer log entry.
This commit is contained in:
parent
2d4c9d8f4a
commit
923cbea2af
1 changed files with 14 additions and 4 deletions
|
@ -1046,10 +1046,20 @@ static RegisterPrimOp primop_trace({
|
||||||
static void prim_warn(EvalState & state, const PosIdx pos, Value * * args, Value & v)
|
static void prim_warn(EvalState & state, const PosIdx pos, Value * * args, Value & v)
|
||||||
{
|
{
|
||||||
state.forceValue(*args[0], pos);
|
state.forceValue(*args[0], pos);
|
||||||
if (args[0]->type() == nString)
|
|
||||||
printMsg(lvlWarn, ANSI_WARNING "warning:" ANSI_NORMAL " %1%", args[0]->string_view());
|
{
|
||||||
else
|
BaseError msg(args[0]->type() == nString
|
||||||
printMsg(lvlWarn, ANSI_WARNING "warning:" ANSI_NORMAL " %1%", ValuePrinter(state, *args[0]));
|
? std::string(args[0]->string_view())
|
||||||
|
: ({
|
||||||
|
std::stringstream s;
|
||||||
|
s << ValuePrinter(state, *args[0]);
|
||||||
|
s.str();
|
||||||
|
}));
|
||||||
|
msg.atPos(state.positions[pos]);
|
||||||
|
auto info = msg.info();
|
||||||
|
info.level = lvlWarn;
|
||||||
|
logWarning(info);
|
||||||
|
}
|
||||||
|
|
||||||
if (evalSettings.builtinsAbortOnWarn) {
|
if (evalSettings.builtinsAbortOnWarn) {
|
||||||
state.error<Abort>("aborting to reveal stack trace of warning, as abort-on-warn is set").debugThrow();
|
state.error<Abort>("aborting to reveal stack trace of warning, as abort-on-warn is set").debugThrow();
|
||||||
|
|
Loading…
Reference in a new issue