跳轉到內容

Rebol 程式設計/throw-on-error

來自華夏公益教科書,開放的書籍,開放的世界
THROW-ON-ERROR blk 

評估一個塊,如果它導致錯誤,則丟擲該錯誤。

THROW-ON-ERROR 是一個函式值。

  • blk -- (型別:塊)

(特殊屬性)

[編輯 | 編輯原始碼]
  • 丟擲

原始碼

[編輯 | 編輯原始碼]
throw-on-error: func [
    {Evaluates a block, which if it results in an error, throws that error.} 
    [throw] 
    blk [block!]
][
    if error? set/any 'blk try blk [throw blk] 
    get/any 'blk
]
華夏公益教科書