Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: 23e5284266
Fetching contributors…

Cannot retrieve contributors at this time

file 65 lines (62 sloc) 1.289 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65
Rebol [
Title: "Catch-any"
File: %catch-any.r
Author: "Ladislav Mecir"
Date: 3-Nov-2010/4:58:46+1:00
Purpose: "Catch any REBOL exception"
]

set 'catch-any func [
{catches any REBOL exception}
block [block!] {block to evaluate}
exception [word!] {used to return the exception type}
/local result
] either rebol/version >= 2.100.0 [[
catch/quit [
set/any 'result catch [
set/any 'result loop 1 [
result: try [
; RETURN or EXIT
set exception 'return
set/any 'result do block

; no exception
set exception none
return get/any 'result
]
; an error was triggered
set exception 'error
return result
]
; BREAK or CONTINUE
set exception 'break
return get/any 'result
]
; THROW
set exception 'throw
return get/any 'result
]
; QUIT
set exception 'quit
#[unset!]
]] [[
error? set/any 'result catch [
error? set/any 'result loop 1 [
error? result: try [
; RETURN or EXIT
set exception 'return
set/any 'result do block

; no exception
set exception none
return get/any 'result
]
; an error was triggered
set exception 'error
return result
]
; BREAK
set exception 'break
return get/any 'result
]
; THROW
set exception 'throw
return get/any 'result
]]
Something went wrong with that request. Please try again.