REBOL Programming/throw-on-error

From Wikibooks, open books for an open world
< REBOL Programming
Jump to: navigation, search

USAGE:[edit]

THROW-ON-ERROR blk 

DESCRIPTION:[edit]

Evaluates a block, which if it results in an error, throws that error.

THROW-ON-ERROR is a function value.

ARGUMENTS[edit]

  • blk -- (Type: block)

(SPECIAL ATTRIBUTES)[edit]

  • throw

SOURCE CODE[edit]

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
]