[REBOL] Re: remaking an error ?
From: koopmans:itr:ing:nl at: 24-Oct-2001 11:10
Thanks, Ladislav!
I changed it slightly to test on having an error object.
See below.
--Maarten
remake-error: func
[
{Remake an error from an object}
disarmed [object!] {The object to remake}
/local spec-length spec words
err-mask
]
[
;This determines if we have an error
err-mask: [code type id arg1arg2 arg3 near where ]
;If we have an error the object should have a certain layout
;in terms of fields
either err-mask = intersect err-mask first disarmed
[
;Get the length of the error spec
spec-length: (length? first disarmed) - 3
;Make an empty error spec
spec: make block! spec-length
;Get the defined words in the object
words: copy/part skip first disarmed 2 spec-length
;Bind them to the values in the context of disarmed
bind words in disarmed 'self
;Make the actual spec
repeat word words [insert/only tail spec get word ]
;Throw the error
return make error! spec
]
[
;Not an error, return the original object
disarmed
]
]