mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-27 00:06:16 +02:00
Merge pull request #4514 from sternenseemann/tryeval-doc
Include note about type of catched errors in tryEval documentation
This commit is contained in:
commit
c8937ba9f3
1 changed files with 8 additions and 4 deletions
|
@ -696,10 +696,14 @@ static RegisterPrimOp primop_tryEval({
|
||||||
Try to shallowly evaluate *e*. Return a set containing the
|
Try to shallowly evaluate *e*. Return a set containing the
|
||||||
attributes `success` (`true` if *e* evaluated successfully,
|
attributes `success` (`true` if *e* evaluated successfully,
|
||||||
`false` if an error was thrown) and `value`, equalling *e* if
|
`false` if an error was thrown) and `value`, equalling *e* if
|
||||||
successful and `false` otherwise. Note that this doesn't evaluate
|
successful and `false` otherwise. `tryEval` will only prevent
|
||||||
*e* deeply, so ` let e = { x = throw ""; }; in (builtins.tryEval
|
errors created by `throw` or `assert` from being thrown.
|
||||||
e).success ` will be `true`. Using ` builtins.deepSeq ` one can
|
Errors `tryEval` will not catch are for example those created
|
||||||
get the expected result: `let e = { x = throw ""; }; in
|
by `abort` and type errors generated by builtins. Also note that
|
||||||
|
this doesn't evaluate *e* deeply, so `let e = { x = throw ""; };
|
||||||
|
in (builtins.tryEval e).success` will be `true`. Using
|
||||||
|
`builtins.deepSeq` one can get the expected result:
|
||||||
|
`let e = { x = throw ""; }; in
|
||||||
(builtins.tryEval (builtins.deepSeq e e)).success` will be
|
(builtins.tryEval (builtins.deepSeq e e)).success` will be
|
||||||
`false`.
|
`false`.
|
||||||
)",
|
)",
|
||||||
|
|
Loading…
Reference in a new issue