This user asked a similar question , but did not have a viable solution in the answers, so here I am revising the topic.
I would like to have emails sent from user exceptions in a clean way. I can do this easily with the help of simple old errors from the custom error_handler, but with extended exceptions I'm a bit of a dead end.
The main problem is that I rely on Zend_Mail to have transparent cross-platform mailing, an easy smtp / ssl configuration to use your gmail account and many other goodies. I would like to access my Zend_Mail object in a special exception. Static calls are not really an option I'm ready to use, although it seems to be easiest to use a third-party object in a custom exception. Here is the constructor of the base exception class:
public function __construct($message = null, $code = 0,
Exception $previous = null);
The only solution that, in my opinion, may be appropriate, is to add a parameter for the mail object to the extended exception class, but I do not want all subclasses to go through the mail object. The idea is that perhaps this mail user. it would be better to be an optional addiction.
__ the signature will be created:
public function __construct($mailobj = null, $message = null, $code = 0,
Exception $previous = null);
Pay attention to the order of the parameters, only $ code is required, and it is in the middle of the signature! This creates another problem, but it is already the next day. My question for today is: does anyone have any ideas / suggestions on how to handle dependencies in custom exception classes? Keep in mind that we strive for the code we are testing.
catch, , , catch.