When should I use Write-Error vs. Throw? Terminating vs. non-terminating errors
Looking at a Get-WebFile script over on PoshCode, http://poshcode.org/3226 , I noticed this strange-to-me contraption: $URL_Format_Error = [string]"..." Write-Error $URL_Format_Error return What is the reason for this as opposed to the following? $URL_Format_Error = [string]"..." Throw $URL_Format_Error Or even better: $URL_Format_Error = New-Object System.FormatException "..." Throw $URL_Format_Error As I understand, you should use Write-Error for non-terminating errors, and Throw for terminating errors, so it seems to me that you should not use Write-Error followed by Return. Is there a