Skip to content

Instantly share code, notes, and snippets.

@svandragt
Last active August 29, 2015 14:26
Show Gist options
  • Select an option

  • Save svandragt/cb7c2003cdf8f0a9d5c7 to your computer and use it in GitHub Desktop.

Select an option

Save svandragt/cb7c2003cdf8f0a9d5c7 to your computer and use it in GitHub Desktop.
FogBugz: BugzScout Automatic Crash Reporting using powershell
$ErrorActionPreference = "Stop"
#region functions - put this in an include and add it to every script
function DoTrap() {
$script = $_.InvocationInfo.ScriptName
$line = $_.InvocationInfo.ScriptLineNumber
$_errorDetails = $Error[0] | fl * -force | Out-string
if (Submit-BugzScoutReport -Description "TEST: $script:$line" -Extra $_errorDetails) {
Write-Host "Error reported."
} else {
Write-Warning "Error could not be reported."
}
}
#endregion
# Set the trap and force the Error
trap { DoTrap }
1/0
# A minimal module
function Submit-BugzScoutReport {
param(
$Description,
$Extra,
$ScoutProject = 'Your Project'
)
$r = @{}
$r.ScoutUserName = 'BugzScout'
$r.ScoutProject = $ScoutProject
$r.ScoutArea = 'Misc'
$r.Description = $Description
$r.Extra = $Extra
return Invoke-RestMethod http://your.fogbugz.url/scoutSubmit.asp -Body $r
}
Export-ModuleMember -Function "*"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment