我偶然发现了这一点,只是想确保这不是Rebol设计中的一个小故障。我有以下代码,似乎成功捕获了VID环境中的所有程序错误。
view layout [
across
label "Rebol Command:"
f: field [
do f/text
focus f
] return
button "Error 1" [
print this-is-an-error-1
]
button "Error 2" [
print this-is-error-2
]
time-sensor: sensor 0x0 rate 1000
feel [
engage: func [face action event] [
if action = 'time [
time-sensor/rate: none
show face
if error? err: try [
do-events
true ; to make the try happy
][
the-error: disarm :err
? the-error
; reset sensor to fire again
time-sensor/rate: 1000
show face
focus f
]
]
]
]
do [
focus f
]
]
答案 0 :(得分:3)
这不是一个小问题 - do-events
确实是在错误发生之前运行的调度程序。我建议将错误处理程序与布局模型本身解耦:
view/new layout [
across
label "Rebol Command:"
f: field [
do f/text
focus f
] return
button "Error 1" [
print this-is-an-error-1
]
button "Error 2" [
print this-is-error-2
]
do [
focus f
]
]
forever [
either error? err: try [
do-events
][
the-error: disarm :err
? the-error
focus f
][
break
]
]