下面是我的code:
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
}
我想替换#掷自定义异常
与code,这将导致捕捉
来火。我该怎么办呢?
I'd like to replace # Throw custom exception
with code that will cause the Catch
to fire. How can I do that?
不知道我真正得到你的问题,但似乎所有你想要做的是:
Not sure I really get your question, but it seems like all you want to do is to:
throw "message for the exception"
上一篇:如何添加动画,windows窗体元素呢?窗体、元素、动画、windows
下一篇:如何一个WinForm中的FormClosing事件prevent结算及处理?事件、WinForm、FormClosing、prevent