What is the best method for catching an error thrown by a construct function in PHP?
The method I have gone for is this but I have not seen this used anywhere else so I am unsure about it:
try{
$connection = new test(/*Some Params*/);
}catch(Exception $e) {
echo 'Caught exception: ',$e->getMessage(),"\n";
}
Any advice much appreciated, thanks
For the purposes of other people reading this question, it is a duplicate of:
How to treat exceptions in constructor best?
It appears that the method I have mentioned above in my question is indeed correct.