Created
August 1, 2016 17:39
-
-
Save gregjhogan/2c78cf90d239a0e0918f29b680d8b04d to your computer and use it in GitHub Desktop.
Catch all errors from commands (including native) run in a powershell script
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $ErrorActionPreference = 'Stop' | |
| try | |
| { | |
| npm install bogus-package 2>&1 | |
| } | |
| catch | |
| { | |
| Write-Host "Error: $_" | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
man you're a lifesaver
thanks a lot!