Question:
What is considered to be \"Best practice\" - and why - of handling errors in a constructor?.
\"Best Practice\" can b
I prefer:
croak
with an informative message when something goes wrong.In addition, returning undef
(instead of croaking) is fine in case the users of the class may not care why exactly the failure occurred, only if they got a valid object or not.
I despise easy to forget is_valid
methods or adding extra checks to ensure methods are not called when the internal state of the object is not well defined.
I say these from a very subjective perspective without making any statements about best practices.