scope() statements and return

Regan Heath via Digitalmars-d digitalmars-d at puremagic.com
Wed Oct 8 06:39:45 PDT 2014


On Tue, 07 Oct 2014 14:39:06 +0100, Andrei Alexandrescu  
<SeeWebsiteForEmail at erdani.org> wrote:

> On 10/7/14, 12:36 AM, monarch_dodra wrote:
>> Hum... But arguably, that's just exception chaining "happening". Do you
>> have any examples of someone actually "dealing" with all the exceptions
>> in a chain in a catch, or actually using the information in a manner
>> that is more than just printing?
>
> No. But that doesn't mean anything; all uses of exceptions I know of are  
> used for just printing. -- Andrei

I have a couple of examples here in front of me.  This is in C#...

[not just for printing]
1. I catch a ChangeConflictException and attempt some basic automatic  
conflict resolution (i.e. column has changed in the database, but I have  
not changed the local version then merge the value from database)

[examining the chain]
2. I catch Exception then test if "ex is TransactionException" AND if  
"ex.InnerException is TimeoutException" (AKA first in chain) then raise a  
different sort of alert (for our GUI to display).

(FYI the reason I don't have a separate catch block for  
TransactionException specifically is that it would involve duplicating all  
the cleanup I am doing in this catch block, all for a 1 line "raise a  
different alert" call - it just didn't seem worth it)

R

-- 
Using Opera's revolutionary email client: http://www.opera.com/mail/


More information about the Digitalmars-d mailing list