Skip to content

Commit 7c9743a

Browse files
committed
broken longwinded paragraph into numbered list
1 parent 701e9df commit 7c9743a

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

1-Draft/RFCNNNN-Make-Terminating-Errors-Terminate-The-Right-Way.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,14 @@ New-Module -Name ThisShouldNotImport {
5151
} | Import-Module
5252
```
5353

54-
If you invoke that snippet, the `ThisShouldNotImport` module imports successfully because the terminating error (`[System.Collections.Generics.List[string]]` is not a valid type name) does not actually terminate the loading of the module. This could cause your module to load in an unexpected state, which is a bad idea. If you loaded your module by invoking a command defined with that module, you won't see the terminating error that was raised during the loading of the module (the terminating error that was raised during the loading of the module is not shown at all in that scenario!), so you could end up with some undesirable behaviour when that command executes even though the loading of the module generated a "terminating" error, and not have a clue why. Further, the Test-RFC command exported by this module produces a terminating error, yet continues to execute after that error. Last, if the caller either loads your module or invokes your command inside of a `try` block, they will see different behaviour. Any execution of code beyond a terminating error should be intentional, not accidental like it is in both of these cases, and it most certainly should not be influenced by whether or not the caller loaded the module or invoked the command inside of a `try` block. Binary modules do not behave this way. Why should script modules be any different?
54+
There are several things wrong with this snippet:
55+
56+
1. If you invoke that snippet, the `ThisShouldNotImport` module imports successfully because the terminating error (`[System.Collections.Generics.List[string]]` is not a valid type name) does not actually terminate the loading of the module. This could cause your module to load in an unexpected state, which is a bad idea.
57+
1. If you loaded your module by invoking a command defined with that module, you won't see the terminating error that was raised during the loading of the module (the terminating error that was raised during the loading of the module is not shown at all in that scenario!), so you could end up with some undesirable behaviour when that command executes even though the loading of the module generated a "terminating" error, and not have a clue why.
58+
1. The Test-RFC command exported by this module produces a terminating error, yet continues to execute after that error.
59+
1. If the caller either loads your module or invokes your command inside of a `try` block, they will see different behaviour.
60+
61+
Any execution of code beyond a terminating error should be intentional, not accidental like it is in both of these cases, and it most certainly should not be influenced by whether or not the caller loaded the module or invoked the command inside of a `try` block. Binary modules do not behave this way. Why should script modules be any different?
5562

5663
Now have a look at the same module definition, this time with some extra scaffolding in place to make sure that terminating errors actually terminate:
5764

0 commit comments

Comments
 (0)