diff options
author | Jade Lovelace <lix@jade.fyi> | 2024-08-12 16:04:22 -0700 |
---|---|---|
committer | Jade Lovelace <lix@jade.fyi> | 2024-08-12 16:04:22 -0700 |
commit | 7e0fee530939cded2cf036ee8b4cc3cfd1103c0e (patch) | |
tree | 2c8efb5417818e3e6400a2c39414988bd2698f9d /doc/manual/rl-next/distinguish-throw-errors.md | |
parent | 5137cea99044d54337e439510a647743110b2d7d (diff) |
release: release notes for 2.91.0
Release created with releng/create_release.xsh
Change-Id: Ieb6ca02d3cf986b28440fce3792e8c38ce80a33e
Diffstat (limited to 'doc/manual/rl-next/distinguish-throw-errors.md')
-rw-r--r-- | doc/manual/rl-next/distinguish-throw-errors.md | 70 |
1 files changed, 0 insertions, 70 deletions
diff --git a/doc/manual/rl-next/distinguish-throw-errors.md b/doc/manual/rl-next/distinguish-throw-errors.md deleted file mode 100644 index 243e33d61..000000000 --- a/doc/manual/rl-next/distinguish-throw-errors.md +++ /dev/null @@ -1,70 +0,0 @@ ---- -synopsis: "Distinguish between explicit throws and errors that happened while evaluating a throw" -cls: 1511 -credits: Qyriad -category: Improvements ---- - -Previously, errors caused by an expression like `throw "invalid argument"` were treated like an error that happened simply while some builtin function was being called: - -``` -let - throwMsg = p: throw "${p} isn't the right package"; -in throwMsg "linuz" - -error: - … while calling the 'throw' builtin - at «string»:2:17: - 1| let - 2| throwMsg = p: throw "${p} isn't the right package"; - | ^ - 3| in throwMsg "linuz" - - error: linuz isn't the right package -``` - -But the error didn't just happen "while" calling the `throw` builtin — it's a throw error! -Now it looks like this: - -``` -let - throwMsg = p: throw "${p} isn't the right package"; -in throwMsg "linuz" - -error: - … caused by explicit throw - at «string»:2:17: - 1| let - 2| throwMsg = p: throw "${p} isn't the right package"; - | ^ - 3| in throwMsg "linuz" - - error: linuz isn't the right package -``` - -This also means that incorrect usage of `throw` or errors evaluating its arguments are easily distinguishable from explicit throws: - -``` -let - throwMsg = p: throw "${p} isn't the right package"; -in throwMsg { attrs = "error when coerced in string interpolation"; } - -error: - … while calling the 'throw' builtin - at «string»:2:17: - 1| let - 2| throwMsg = p: throw "${p} isn't the right package"; - | ^ - 3| in throwMsg { attrs = "error when coerced in string interpolation"; } - - … while evaluating a path segment - at «string»:2:24: - 1| let - 2| throwMsg = p: throw "${p} isn't the right package"; - | ^ - 3| in throwMsg { attrs = "error when coerced in string interpolation"; } - - error: cannot coerce a set to a string: { attrs = "error when coerced in string interpolation"; } -``` - -Here, instead of an actual thrown error, a type error happens first (trying to coerce an attribute set to a string), but that type error happened *while* calling `throw`. |