Skip to content

Commit

Permalink
Improved error handling for Non fatal errors
Browse files Browse the repository at this point in the history
  • Loading branch information
jessehouwing committed Feb 22, 2016
1 parent cdf8097 commit ca1720f
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 20 deletions.
6 changes: 3 additions & 3 deletions extension-manifest.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"manifestVersion": 1,
"id": "jessehouwing-vsts-tfvc-tasks-TEST",
"id": "jessehouwing-vsts-tfvc-tasks",
"name": "TFVC Build Tasks",
"version": "1.0.29",
"version": "1.0.35",
"publisher": "jessehouwing",
"public": false,
"public": true,
"targets": [
{
"id": "Microsoft.VisualStudio.Services"
Expand Down
11 changes: 8 additions & 3 deletions vsts-tfvc-add/TfvcAdd.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -198,9 +198,14 @@ Try
$OnNonFatalError = [Microsoft.TeamFoundation.VersionControl.Client.ExceptionEventHandler] {
param($sender, $e)

Write-Warning "NonFatalError"
Write-Warning $e.Exception.Message
Write-Warning $e.Failure
if ($e.Exception -ne $null -and $e.Exception.Message -ne $null)
{
Write-Warning $e.Exception.Message
}
if ($e.Faulure -ne $null)
{
Write-Warning $e.Failure.ToString()
}
}
$provider.VersionControlServer.add_NonFatalError($OnNonFatalError)

Expand Down
2 changes: 1 addition & 1 deletion vsts-tfvc-add/task.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"version": {
"Major": 1,
"Minor": 0,
"Patch": 97
"Patch": 103
},
"minimumAgentVersion": "1.83.0",
"groups": [
Expand Down
28 changes: 16 additions & 12 deletions vsts-tfvc-checkin/TfvcCheckin.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -116,14 +116,6 @@ function Get-SourceProvider {
}
$success = $false
try {
if ($provider.Name -eq 'TfsGit') {
$provider.CollectionUrl = "$env:SYSTEM_TEAMFOUNDATIONCOLLECTIONURI".TrimEnd('/')
$provider.RepoId = $env:BUILD_REPOSITORY_ID
$provider.CommitId = $env:BUILD_SOURCEVERSION
$success = $true
return New-Object psobject -Property $provider
}

if ($provider.Name -eq 'TfsVersionControl') {
$serviceEndpoint = Get-ServiceEndpoint -Context $distributedTaskContext -Name $env:BUILD_REPOSITORY_NAME
$tfsClientCredentials = Get-TfsClientCredentials -ServiceEndpoint $serviceEndpoint
Expand All @@ -132,6 +124,7 @@ function Get-SourceProvider {
$serviceEndpoint.Url,
$tfsClientCredentials)
$versionControlServer = $provider.TfsTeamProjectCollection.GetService([Microsoft.TeamFoundation.VersionControl.Client.VersionControlServer])
$provider.VersionControlServer = $versionControlServer;
$provider.Workspace = $versionControlServer.TryGetWorkspace($provider.SourcesRootPath)
if (!$provider.Workspace) {
Write-Verbose "Unable to determine workspace from source folder: $($provider.SourcesRootPath)"
Expand Down Expand Up @@ -170,8 +163,7 @@ function Get-SourceProvider {
return New-Object psobject -Property $provider
}

Write-Warning ("Only TfsVersionControl source providers are supported for TFVC tasks. Repository type: $provider")
return
Write-Warning ("Only TfsVersionControl source providers are supported for TFVC tasks. Repository type: $provider") return
} finally {
if (!$success) {
Invoke-DisposeSourceProvider -Provider $provider
Expand Down Expand Up @@ -315,9 +307,21 @@ Try
}
}

$provider = Get-SourceProvider

$OnNonFatalError = [Microsoft.TeamFoundation.VersionControl.Client.ExceptionEventHandler] {
param($sender, $e)

$provider = Get-SourceProvider
if ($e.Exception -ne $null -and $e.Exception.Message -ne $null)
{
Write-Warning $e.Exception.Message
}
if ($e.Faulure -ne $null)
{
Write-Warning $e.Failure.ToString()
}
}
$provider.VersionControlServer.add_NonFatalError($OnNonFatalError)

if ($Recursion -ne "")
{
Expand Down Expand Up @@ -375,8 +379,8 @@ Try
}
Finally
{
$provider.VersionControlServer.remove_NonFatalError($OnNonFatalError)
Invoke-DisposeSourceProvider -Provider $provider
[System.AppDomain]::CurrentDomain.remove_AssemblyResolve($OnAssemblyResolve)
}


Expand Down
2 changes: 1 addition & 1 deletion vsts-tfvc-checkin/task.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"version": {
"Major": 1,
"Minor": 0,
"Patch": 128
"Patch": 134
},
"visibility": [
"Build"
Expand Down

0 comments on commit ca1720f

Please sign in to comment.