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

[REBOL] Re: global error handling?

From: maximo:meteorstudios at: 25-Jul-2003 8:17

From: Andrew Martin [mailto:[andrew--martin--colenso--school--nz]]
> > I ask because I'm wondering if its possible to catch when an unset > word is evaluated... > > Would it still work if silly people like myself did this: > > >> type? do [print "123"] > 123 > == unset!
well that's the worst case scenario, because print does not return a value, but it does exist by itself. But, in your code, there was no error generated, because you wanted to retrieve the type? which actually IS unset... I'd mainly like do something like: ;----------------------------------------------------------------------------------- rebol [] catch-error-hook: error-handler ['unset-word error-data /local word] [ word: error-data/word set word select load %optional-funcs.r error-word either word [ return ; return to code, just before evaluation the word ][ throw 'unset-word ; really generate the error... ] ] value: myfunc ask "done..." ;------------------------------------------------------------------------------------- Here, the hook would set the myfunc word (globaly) just before it actually was going to be evaluated (if the rebol parser didn't find a value for it yet).
> > is there a way to handle an error globaly by putting a "hook" or > appending to a block somewhere deep in the system funcs. > > I don't know if this is helpful or not but the 'throw and 'catch words > might be useful? Perhaps 'try, 'attempt, and 'error! might be useful? >
they are functions, they don't map to the global context, AFAIK they interrupt the error before the error occurs, but divert execution to a new block. Its like saying : I can't find door to room A ... well then, go to room B instead. What I want is to try and find the room A somewhere else (by getting a floorplan!). Another example is getting to call rugby-type server anytime an unset-word is evaluated... -Max