J. Landman Gay wrote:
> On 6/24/2014, 1:02 PM, Graham Samuel wrote:
>> I get a result, "nan", and the catch doesn't fire. Why not? Maybe
>> someone can explain what the engine is doing here - or is it just an
>> obscure bug?
>
> A "catch" only triggers when there is a script error. In this case
> there is no error, "nan" is a legitimate value for a calculation
> that can't be computed.
This conversation raises a broader issue that's concerned me for some
time, and I'm hoping I've just overlooked some rule at play that would
make things more readily understandable:
How can a scripter know in advance which commands require try-catch to
handle errors and which require checking the result?
For example:
decompress and arrayDecode require try-catch, throwing an execution
error if the data passed to them is not in the expected format.
But decrypt throws no execution error at all when unencrypted data is
passed, instead describing that there is a problem in the result.
Is there a simple rule that would allow scripters to understand when
try-catch is necessary and when the result should be checked instead?
If not, should there be?
Or perhaps better yet, could error handling be made uniform, maybe as
part of the Open Language initiative? If so, what would it look like?
--
Richard Gaskin
Fourth World
LiveCode training and consulting: http://www.fourthworld.com
Webzine for LiveCode developers: http://www.LiveCodeJournal.com
Follow me on Twitter: http://twitter.com/FourthWorldSys
_______________________________________________
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode