Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

remaking an error ?

 [1/11] from: cyphre:seznam:cz at: 23-Oct-2001 14:40


Hi Maarten, I think my function (used in vconsole) might help you: ----------------------------begin of code---------------------- parse-error: func [ error [object!] /local type id arg1 arg2 arg3 wh ][ type: error/type id: error/id wh: mold get/any in error 'where either any [ unset? get/any in error 'arg1 unset? get/any in error 'arg2 unset? get/any in error 'arg3 ][ arg1: arg2: arg3: "(missing value)" ][ arg1: error/arg1 arg2: error/arg2 arg3: error/arg3 ] return rejoin [ "** " system/error/:type/type ": " reduce either block? system/error/:type/:id [ bind to-block system/error/:type/:id 'arg1 ][ form system/error/:type/:id ] newline "** Where: " wh newline "** Near: " error/near ] ] ------------------end of code------------------------------ regards, Cyphre

 [2/11] from: koopmans:itr:ing:nl at: 23-Oct-2001 16:02


Thanks, exactly what I was looking for. --Maarten On Tuesday 23 October 2001 14:40, you wrote:

 [3/11] from: koopmans:itr:ing:nl at: 23-Oct-2001 13:09


Hi, I would like to remake an error so I can have transparent error propagation in Rugby. So: a: make error! "test" b: disarm a c: remake-error b for *arbitraty* types of errors Now what does remake-error have to look like? --Maarten

 [4/11] from: lmecir:mbox:vol:cz at: 23-Oct-2001 22:54


Hi Maarten, would this help you a bit? remake-error: function [ disarmed [object!] ] [spec-length spec words] [ spec-length: (length? first disarmed) - 3 spec: make block! spec-length words: copy/part skip first disarmed 2 spec-length bind words in disarmed 'self repeat word words [insert/only tail spec get word] return make error! spec ]

 [5/11] 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 ] ]

 [6/11] from: lmecir:mbox:vol:cz at: 24-Oct-2001 13:29


Hi Maarten, ...
> I changed it slightly to test on having an error object.
...
> ;If we have an error the object should have a certain layout > ;in terms of fields > either err-mask = intersect err-mask first disarmed
... Why didn't you test for (err-mask = next first disarmed) ? Cheers Ladislav

 [7/11] from: koopmans:itr:ing:nl at: 24-Oct-2001 13:41


I may choose not to test on the complete set in err-mask, i.e. I only want to know if the set err-mask is contained in first disarmed. Because you never know if this may change in future releases.... --Maarten

 [8/11] from: lmecir:mbox:vol:cz at: 24-Oct-2001 14:09


You are right, but I think, that it would be better to change it as follows then, wouldn't it? equal? first disarm make error! "" first disarmed Cheers Ladislav P.S. what I mean is, that even: disarmed: make object! [ code: 800 near: [probe disarm make error! ""] type: 'user id: 'message arg1: "" arg2: none arg3: none where: none ] is not a disarmed error.

 [9/11] from: koopmans:itr:ing:nl at: 24-Oct-2001 14:24


yes, but making an error may be more expensive than do the comparison between two blocks. A trade off... --Maarten

 [10/11] from: lmecir:mbox:vol:cz at: 24-Oct-2001 15:16


Not in this case: use [err-mask] [ err-mask: first disarm make error! "" remake-error: func [ {Remake an error from an object} disarmed [object!] {The object to remake} /local spec-length spec words ] [ ;This determines if we have an error ;If we have an error the object should have a certain layout ;in terms of fields either err-mask = first disarmed ... ] ]

 [11/11] from: nitsch-lists:netcologne at: 24-Oct-2001 16:01


RE: [REBOL] Re: remaking an error ? Hi Marten. what do you really want to do? Since disarmed errors seems copies of the original, you can simply throw them again?
>> error? a: try [make error! "bang"]
== true
>> probe disarm a
make object! [ code: 800 type: 'user id: 'message arg1: "bang" arg2: none arg3: none near: [make error! "bang"] where: none ]
>> a
** User Error: bang ** Near: make error! "bang"
>>
;-) Volker [koopmans--itr--ing--nl] wrote: