这是我的代码:
Function Foo {
If (1 -Eq 2) {
# Do stuff
}
Else {
# Throw custom exception
}
}
Try {
Foo
Write-Host "Success"
}
Catch {
$ErrorMessage = $_.Exception.InnerException.Message
Write-Host "Failure"
# Do stuff with the error message
}
Run Code Online (Sandbox Code Playgroud)
我想替换# Throw custom exception会导致Catch触发的代码.我怎样才能做到这一点?
man*_*lds 19
不确定我真的得到你的问题,但似乎你想要做的就是:
throw "message for the exception"
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
13045 次 |
| 最近记录: |