Re: Exceptions creating Exceptional Problems!

Abhijit Menon-Sen <[email protected]> Sun, 9 Jan 2005 11:02:44 +0530
Newsgroups gmane.user-groups.linux.delhi.devel
Message-ID <[email protected]>
At 2005-01-08 18:35:25 -0500, [email protected] wrote:
>
> http://makuchaku.blogspot.com/2005/01/exceptions-creating-exceptional.html

[To summarise from that web page:

    try {
        Socket s;
        // ...
    }
    catch (Error e) {
        s.foo();
    }
]

> In a nutshell, accessing the object in which exception occured is not
> being possible in catch block.

In a nutshell, that's exactly how it is supposed to work. The scope of
the object is the try block, and it is not visible outside; and it is
destroyed when execution leaves the scope (either due to an exception
or otherwise).

It's the same reason that this won't work:

    if ( ... ) {
        Socket s;
    }

    s.foo();

-- ams