throw
builtins.throw
Primop
Docs pulled from | This Revision | 1 day ago
Nix manual
Takes 1 arguments
s
Throw an error message s. This usually aborts Nix expression
evaluation, but in nix-env -qa and other commands that try to
evaluate a set of derivations to get information about those
derivations, a derivation that throws an error is silently skipped
(which is not the case for abort).
Noogle detected
Detected Type
throw :: String -> Never
Implementation
This function is implemented in c++ and is part of the native nix runtime.
static RegisterPrimOp primop_throw(
{.name = "throw",
.args = {"s"},
.doc = R"(
Throw an error message *s*. This usually aborts Nix expression
evaluation, but in `nix-env -qa` and other commands that try to
evaluate a set of derivations to get information about those
derivations, a derivation that throws an error is silently skipped
(which is not the case for `abort`).
)",
.impl = [](EvalState & state, const PosIdx pos, Value ** args, Value & v) {
NixStringContext context;
auto s =
state.coerceToString(pos, *args[0], context, "while evaluating the error message passed to builtin.throw")
.toOwned();
state.error<ThrownError>(s).setIsFromExpr().debugThrow();
}})