Should I use an exception to pass an instance of my object?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I'm facing a situation where I want to use an exception in my __construct method to notify the caller that the input data is invalid. But I because I want to avoid having to use a static constructor method or validate the data before the __construct call I thought I would just modify the data based on my needs and at the very end of __construct throw a custom exception what holds the instance of $this so it can still be used at the callers side.

Example: https://3v4l.org/pbIWR

Should I do it?


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux