Roedy Green wrote:
> On Fri, 09 May 2008 04:06:49 GMT, thufir <hawat.thufir@[EMAIL PROTECTED]
>
> wrote, quoted or indirectly quoted someone who said :
>
>> The makeGuest is working fine, probably because the data is fine. If
the
>> constructor of Guest throws a DataException, though, I wouldn't want
>> makeGuest to return a new Guest! I'm not quite sure what it should do,
>> if not that, though...
>
> If you do something like
>
> Thing thing = new Thing();
>
> And the constructor throws an exception, thing will be unmodified
> since the assigment is the last step.
In this particular case, 'thing' will fall out of scope; there won't be a
'thing' to be unmodified.
This scope vs. exception tension occurs often in making connections or
grabbing other resources, for example.
im****t some.version.of.Resource;
Resource res = null;
try
{
res = getResource();
}
catch ( SomeException exc )
{
handle( exc );
// for some reason we want to continue
}
....
// time to close
if ( res != null )
{
res.close();
res = null;
}
--
Lew


|