Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Java Help > Re: throwing ex...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 7 of 9 Topic 16067 of 16245
Post > Topic >>

Re: throwing exceptions on instantiation

by Lew <lew@[EMAIL PROTECTED] > May 10, 2008 at 08:24 AM

thufir wrote:
> On Fri, 09 May 2008 07:55:17 -0700, Daniel Pitts wrote:
> 
>>> 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...
>>>
>>> Should I try makeGuest first?  Would it make sense to have a
>>> tryMakeGuest () method?
>> Just don't catch the exception in makeGuest. Let it propagate up to
>> whoever calls makeGuest.
> 
> 
> I'll take another look at it, but I think that I was getting a compile 
> error, uncaught exception, when I tried that.

Sounds like the exception was not caught by the invoker of the method,
then. 
The method itself has to declare any checked exceptions it throws, or the 
rethrow will fail.

-- 
Lew
 




 9 Posts in Topic:
throwing exceptions on instantiation
thufir <hawat.thufir@[  2008-05-09 04:06:49 
Re: throwing exceptions on instantiation
Knute Johnson <nospam@  2008-05-08 22:04:19 
Re: throwing exceptions on instantiation
thufir <hawat.thufir@[  2008-05-09 09:31:30 
Re: throwing exceptions on instantiation
Knute Johnson <nospam@  2008-05-09 09:15:52 
Re: throwing exceptions on instantiation
Daniel Pitts <newsgrou  2008-05-09 07:55:17 
Re: throwing exceptions on instantiation
thufir <hawat.thufir@[  2008-05-10 07:13:22 
Re: throwing exceptions on instantiation
Lew <lew@[EMAIL PROTEC  2008-05-10 08:24:08 
Re: throwing exceptions on instantiation
Roedy Green <see_websi  2008-05-10 13:03:09 
Re: throwing exceptions on instantiation
Lew <lew@[EMAIL PROTEC  2008-05-10 09:52:24 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Fri Jul 18 20:59:53 CDT 2008.