Looking at a Get-WebFile script over on PoshCode, http://poshcode.org/3226, I noticed this strange-to-me contraption:
$URL_Format_Error = [string]\"...\" Wri
Write-Error allows the consumer of the function to suppress the error message with -ErrorAction SilentlyContinue (alternatively -ea 0). While throw requires a try{...} catch {..}
Write-Error
-ErrorAction SilentlyContinue
-ea 0
throw
try{...} catch {..}
To use a try...catch with Write-Error:
try { SomeFunction -ErrorAction Stop } catch { DoSomething }