|
When using trap, does the trap block need to be placed before the lines that could throw an exception, or can it be placed anywhere while it's still in the same block?
|
# ¿ Jun 21, 2011 18:42 |
|
|
# ¿ May 2, 2024 03:30 |
|
adaz posted:It can be placed before, it will attempt the trap statement in the block first, doesn't matter if it comes before or after the code. This is a pretty good overview of traping in powershell http://huddledmasses.org/trap-exception-in-powershell/. Honestly ever since v2 I've switched everything to try/catch blocks Thanks for the info. I found that page before, but I didn't remember if it explicitly said anything about where trap blocks need to be placed.
|
# ¿ Jun 21, 2011 19:31 |