REBOL Programming/throw-error

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

USAGE:[edit]

THROW-ERROR err-type err-id args 

DESCRIPTION:[edit]

Causes an immediate error throw with the provided information.

THROW-ERROR is a function value.

ARGUMENTS[edit]

  • err-type -- (Type: word)
  • err-id -- (Type: word)
  • args -- (Type: any)

SOURCE CODE[edit]

throw-error: func [
    {Causes an immediate error throw with the provided information.} 
    err-type [word!] 
    err-id [word!] 
    args
][
    parse args: compose [(:args)] [0 3 [args: any-function! (
                change/only args copy/deep third first args
            ) | skip]] 
    args: head args 
    throw make error! reduce [err-type err-id pick args 1 pick args 2 pick args 3]
]