如何通知我普米卡任务列表中任何任务中的任何错误。?
在通知处理程序中,我希望显示任务失败的窗口通知。但是psake吞下了异常并将其写入控制台。
更新:这里的是Psake脚本中的代码,它吞噬了错误
# if we are running in a nested scope (i.e. running a psake script from a psake script) then we need to re-throw the exception
# so that the parent script will fail otherwise the parent script will report a successful build
$inNestedScope = ($psake.context.count -gt 1)
if ( $inNestedScope ) {
throw $_
} else {
if (!$psake.run_by_psake_build_tester) {
WriteColoredOutput $error_message -foregroundcolor Red
}
}发布于 2015-04-29 12:13:09
这就是我处理这个问题的方法。首先,在这个异常吞咽代码之前的某个地方,创建一个名为$errors的新对象,它是一个ArrayList类型(对于构建消息集合非常有用和快速)。
$errors = New-Object System.Collections.ArrayList
# if we are running in a nested scope (i.e. running a psake script from a psake script) then we need to re-throw the exception
# so that the parent script will fail otherwise the parent script will report a successful build
$inNestedScope = ($psake.context.count -gt 1)
if ( $inNestedScope ) {
throw $_
} else {
if (!$psake.run_by_psake_build_tester) {
WriteColoredOutput $error_message -foregroundcolor Red
$errors.Add($error[0])
}
}
<#.the rest of your code...#>
if ($errors.Count -ne 0){
Write-Warning 'A number of errors were encountered during the processing of this task, please review them, below'
$errors
}这是一个非常简单的方法,可能会完成这项工作。我们仍然允许将错误写到屏幕上,但也收集它们以显示脚本中的其他部分。
如果这个方法不是你想要的,请告诉我?
https://stackoverflow.com/questions/29926946
复制相似问题