Rebol Programming/throw-on-error

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

USAGE:[edit | edit source]

THROW-ON-ERROR blk 

DESCRIPTION:[edit | edit source]

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

THROW-ON-ERROR is a function value.

ARGUMENTS[edit | edit source]

  • blk -- (Type: block)

(SPECIAL ATTRIBUTES)[edit | edit source]

  • throw

SOURCE CODE[edit | edit source]

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
]