Discussions about error handling in PowerShell revolve around two things: the statements used in error handling, and what constitutes an error that needs to be handled.
PowerShell error handling had a rocky start. The Version 1.0 error handling statement was the trap statement. This statement is similar to the
ON ERROR GOTO statement in Visual Basic 6. This was a functional way to do error handling, but it was not what most programming languages had been using for the last decade. If a trap statement is included in a scope, when an exception (called a terminating
error in PowerShell terminology) occurs in that scope, the execution is stopped and the trap statement is executed. By default, trap statements ...