title: Catching exceptions while running git commands in PowerShell
body: <p>I have just started leaning Git and Powershell and trying to create a not complex PS script to sync a branch from Git.</p>
  
  <p>I want to catch possible exceptions that can occur during execution of git commands in powershell. </p>
  
  <p>Here is an extract from my code, where I try to use a standard try/catch approach: </p>
  
  <pre><code>try { git reset --hard origin/master }
      catch  {
  
                  LogMessage ("Failure on syncing files from the GitHub")
                  LogMessage $_.Exception.Message;
                  Return
  
              } 
  </code></pre>
  
  <p>LogMessage is a function to output exceptions in a file. I use the Posh-Git to run the script.</p>
  
  <p>For some reasons this doesn't work. Exceptions are not gathered by the catch, return command is not executed and the script still running.</p>
  
  <p>What I have missed? </p>
  
  <p>Thanks in advance and have a good day.</p>