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

[REBOL] Re: Help me, Obi Reb Kenobi, you're my only hope!

From: edanaii:cox at: 28-Aug-2002 18:33

Carl Read wrote:
>Hee - wasted time on this myself today! > >The problem is that 'print doesn't return a value when 'Fred is >expecting one... > >>>Fred: print "What's wrong with this?" >>> >What's wrong with this? >** Script Error: Fred needs a value >** Near: Fred: print "What's wrong with this?" > >and it's not trapped by your error routine as 'Fred is outside the >block that's being 'try'ed. Place 'Fred inside it and you'll trap >the error... > >>>If Error? try [Fred: Print "See?"][Print "Whatever!"] >>> >See? >Whatever! >
Yes. But the value that I was trying to assign Fred was the error that was to occur when I attempted my action. More accurately, I have written a couple of daemons, that execute a command that I pass to it as a parameter. I wanted the daemon to send out an email if it could not execute the action it was assigned. Something like this (where Action is the variable that holds the statement to be executed: If Error? Error: Try [ Do Action] [ Send Warning email ] Realizing that Try is similar to Do, I even used: If Error? Error: Try [ Action] [ Send Warning email ] The first executed without issue, making me think that everything was executing OK; it wasn't. The second gave me the "no value" error. But this is why I'm confused: If try is to be used to help trap errors, why does it care if a value is set or not? That's why I pointed out that I got the error when issuing a "write" command. If anything needed to be trapped, it was that. How else can I tell if a file is not there, or I don't have access permission, or the file system is too full, etc? The above statements, BTW, were taken (in form) from a REBOL manual. They were text-book examples...
>It's possible to write a function that'll check for nothing returned, >as the any-type! datatype will accept nothing. ie... > >nothing-check: func [value [any-type!]][ > either value? 'value [join "that was: " value]['nothing...] >] > >>>nothing-check "abc" >>> >== "that was: abc" > >>>nothing-check print "abc" >>> >abc >== nothing... > >>>nothing-check join "abc" "xyz" >>> >== "that was: abcxyz" > >>>nothing-check >>> >== nothing... >
I suppose I could use that technique as part of my error trapping, the question still remains: why? Error trapping should have to do with trapping errors, not (just) return values. -- Sincerely, | Cold Hearted Orb, that rules the night. Removes Ed Dana | the colours from our sight! Red is gray and Software Developer | yellow white! But we decide which is right... 1Ghz Athlon Amiga | And which is an illusion! | -- The Moody Blues, Late Lament.