query
On this page

addErrorContext

builtins.addErrorContext

Primop
Docs pulled from | This Revision | about 1 hour ago


Contribute
Enhance the ecosystem with your expertise! Contribute to fill the gaps in documentation. Your input can make a difference.

Noogle detected

Aliases

Detected Type
addErrorContext :: String -> a -> a

Implementation

This function is implemented in c++ and is part of the native nix runtime.

src/libexpr/primops.cc:1016

static void prim_addErrorContext(EvalState & state, const PosIdx pos, Value ** args, Value & v)
{
    try {
        state.forceValue(*args[1], pos);
        v = *args[1];
    } catch (Error & e) {
        NixStringContext context;
        auto message = state
                           .coerceToString(
                               pos,
                               *args[0],
                               context,
                               "while evaluating the error message passed to builtins.addErrorContext",
                               false,
                               false)
                           .toOwned();
        e.addTrace(nullptr, HintFmt(message), TracePrint::Always);
        throw;
    }
}