Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save gregjhogan/2c78cf90d239a0e0918f29b680d8b04d to your computer and use it in GitHub Desktop.

Select an option

Save gregjhogan/2c78cf90d239a0e0918f29b680d8b04d to your computer and use it in GitHub Desktop.
Catch all errors from commands (including native) run in a powershell script
$ErrorActionPreference = 'Stop'
try
{
npm install bogus-package 2>&1
}
catch
{
Write-Host "Error: $_"
}
@TravkinAlex
Copy link
Copy Markdown

TravkinAlex commented Apr 24, 2020

man you're a lifesaver
thanks a lot!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment