<commit_before>Rebol [
	Title: "Catch-any"
	File: %catch-any.r
	Author: "<NAME>"
	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
]]<commit_msg>catch-any now RETURN/REDO -proof<commit_after>Rebol [
	Title: "Catch-any"
	File: %catch-any.r
	Author: "<NAME>"
	Date: 14-Feb-2013/21:09:57+1:00
	Purpose: "Catch any REBOL exception"
]

make object! [
	do-block: func [
		; helper for catching RETURN, EXIT and RETURN/REDO in R3
		block [block!]
		exception [word!]
		/local result
	] [
		set exception 'return
		set/any 'result do block
		set exception none
		return get/any 'result
	]

	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 [
						; catch RETURN, EXIT and RETURN/REDO
						; using the DO-BLOCK helper call
						do [set/any 'result do-block block exception]
						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
	]]
]
{'fraction_non_alphanumeric': 0.09714673913043478, 'fraction_numerical': 0.014605978260869566, 'mean_word_length': 2.5185185185185186, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4897385', 'n_tokens_mistral': 1276, 'n_tokens_neox': 997, 'n_words': 336}