Ron,

I think Miguel is trying to say that without the new syntax a division by zero
interrupts the execution of the code inside try-catch and gives control to the
code following the catch clause.

While with the new syntax it is able to return a value for the division by
zero operation and continue as if there was no error at all.

Maurilio.


Miguel Angel Marchuet wrote:
> As I see, I can't explain it with my English.
> 
> There are recoverable errors as zero division. With the codeblock that I
> propose we can solve this problem and the code can
> continue without caching resolved exceptions.
> 
> Actually this is simply impossible because this codeblock is harcoded to
> catch all errors.
> 
> LOCAL b
> 
> TRY WITH {|o| MyError( o ) }
> 
>     b := 1 / 0 // THIS ERROR IS NOT CACHED, b prints 0
> 
>     ...
> 
>     // the rest of code is executed
> 
>     ... // The rest of errors are cached
>        
> CATCH oErr
>     ...
> END TRY
> 
> FUNCTION MyError( e )
> 
>     // by default, division by zero yields zero
>     IF ( e:genCode == EG_ZERODIV )
>        RETURN 0
>     ENDIF
> 
> RETURN .F.
> 
> It is only an example of use.
> 
> 
> Ron Pinkas escribió:
>> Miguel,
>>
>> Sorry but you are mixing 2 different issues. The TRY construct in all
>> those languages will still raise the exception, if you have any error.
>> The CATCH syntax simply allows you to have different catchers for
>> different errors, at different levels. Those samples you posted
>> function exactly like this:
>>
>>    TRY
>>         ? a /0
>>    CATCH e
>>         SWITCH e:genCode
>>              CASE EG_ZERODIV
>>                  ? "Caught division by 0"
>>                  EXIT
>>
>>               DEFAULT
>>                    Throw( e )
>>          END
>>    FINALLY
>>          ? " In finally"
>>    END
>>
> 
> 

-- 
 __________
|  |  | |__| Maurilio Longo
|_|_|_|____| farmaconsult s.r.l.



-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
xHarbour-developers mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/xharbour-developers

Reply via email to