How to handle exceptions in constructor?
- From: "George George via JavaKB.com" <forum@xxxxxxxxxx>
- Date: Mon, 27 Jun 2005 03:18:40 GMT
Hello everyone,
When exceptions occur in constructor so that the instance of the object can
not be created, should we throw the exception to the invoker of the
constructor or simply catch the exception (and not throw it again)?
I think we should not catch the exception (and not throw it again), since in
this approach, the invoker can not see whether the instance of the object has
been created successfully.
I think we should throw the exception to let the invoker know that the
instance of the object has not been created successfully, so that the invoker
can peform appropriate actions. But I am not quite sure whether I am correct
since I have not seen any constructors which throw exceptions before.
Could anyone help?
Thanks in advance,
George
--
Message posted via JavaKB.com
http://www.javakb.com/Uwe/Forums.aspx/java-setup/200506/1
.
- Follow-Ups:
- Re: How to handle exceptions in constructor?
- From: Stefan Schulz
- Re: How to handle exceptions in constructor?
- From: Thomas Fritsch
- Re: How to handle exceptions in constructor?
- Prev by Date: Re: How can I get the input from keyboard without using swing?
- Next by Date: formatting floats in a table
- Previous by thread: How can I get the input from keyboard without using swing?
- Next by thread: Re: How to handle exceptions in constructor?
- Index(es):
Relevant Pages
|