Merge pull request #11723 from roberth/doc-tryEval

doc: Explain why tryEval does not return the message
This commit is contained in:
tomberek 2024-10-21 08:33:07 -04:00 committed by GitHub
commit 63e6672251
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -944,6 +944,9 @@ static RegisterPrimOp primop_tryEval({
`let e = { x = throw ""; }; in
(builtins.tryEval (builtins.deepSeq e e)).success` will be
`false`.
`tryEval` intentionally does not return the error message, because that risks bringing non-determinism into the evaluation result, and it would become very difficult to improve error reporting without breaking existing expressions.
Instead, use [`builtins.addErrorContext`](@docroot@/language/builtins.md#builtins-addErrorContext) to add context to the error message, and use a Nix unit testing tool for testing.
)",
.fun = prim_tryEval,
});