I'm using PowerShell v4 to call the svn command line tool and can't figure out of way carrying out basic error handling. I've tried capturing the results any svn command to a variable, using try-catch blocks, even trapping the exception doesn't work
The following checkout intentionally generates an 'Authentication failed' error in the console:
trap [SystemException]
{
Write-Output "ERROR: $_";exit 1
}
try
{
$log = svn.exe checkout $Url $Path --no-auth-cache --non-interactive --username "username" --password "Password"
}
catch
{
write-host "$_"
}
In the console pane, the error is displayed:
svn.exe : svn: E215004: Authentication failed and interactive prompting is disabled; see the --force-interactive option At C:\dev\Temp\script.ps1:30 char:8 + $log = svn.exe checkout $Url $Path --no-auth-cache --non-interactive --username ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : NotSpecified: (svn: E215004: A...eractive option:String) [], RemoteException + FullyQualifiedErrorId : NativeCommandError svn: E215004: Unable to connect to a repository at URL 'http://source.com/' Authentication failed
The $log variable is never assigned the above output, the try-catch block and generic trap are both ignored.
Surely someone out there has automated some SVN before, and how effective can automation be without even basic error handling?