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