Powershell:如果在try块中引发非终止错误,则变为终止错误

时间:2020-04-08 17:19:34

标签: powershell-5.0

我需要一些指针来了解这种行为:

try

通常返回非终止错误并返回相同参数的函数在import { Override, Data, motionValue, useTransform } from "framer" // Keep track of the state of our application const data = Data({ isPastLimit: false }) // Create a MotionValue to track contentOffsetY const contentOffsetY = motionValue(0) // Listen for changes to contentOffsetY contentOffsetY.onChange(offset => (data.isPastLimit = offset < -150)) // Apply this override to your scroll component export function TrackScroll(): Override { return { contentOffsetY: contentOffsetY } } // Apply this override to a frame containing your Sticky Nav export function ShowCTAIfPastLimit(): Override { return { animate: data.isPastLimit ? { y: -133 } : { y: 0 }, } } 块中时会产生终止错误。

为什么以及何时发生这种情况? 这和每个功能有关吗?

1 个答案:

答案 0 :(得分:0)

如果它在try / catch中起作用,则是终止错误。鲜为人知,但是有两种终止错误,脚本终止和命令终止。尝试会看到命令终止错误并对其执行操作。 “ 1/0”也是命令终止。

try { 1/0; 'hi' } catch { 'caught' } 

caught

“找不到路径”不是终止错误:

try { dir foo } catch { 'caught' } 

Get-ChildItem: Cannot find path '/Users/js/foo' because it does not exist.
相关问题