throw vs the result

Andre Garzia soapdog at mac.com
Sat Apr 30 19:31:39 EDT 2005


On Apr 30, 2005, at 6:22 PM, Dar Scott wrote:

> I was wondering what people prefer as far as "fatal" errors in 
> executing a custom command, such as in a library.
>
> Should that be in a non-empty value returned by result()?
>
> Or should that cause some error message to the thrown?
>
> Or does it depend on the error?
>
> Dar

Dar,

my convention is:
* Use return codes if the error is not a critical one. more like a 
mistake then an error.
* Use throw if the error is a karma-burning pyrotechinical mayhem from 
hell.

This way I can split my code inside a Try/Catch structure, inside the 
try clause I work the code fine taking notice of possible mistakes and 
avoiding them. If something really wrong happens then the catch block 
will take care of it. This makes my code more manageable. Also it 
brings a distinction between errors and mistakes/warnings which I think 
is good.

Cheers
andre


-- 
Andre Alves Garzia ð 2004 ð BRAZIL
http://studio.soapdog.org



More information about the use-livecode mailing list