How to handle Swift_TransportException in Silex
问题 I'm having quiet weird problem with catching SwiftMailer's exceptions in Silex. I want to send an email like this: try { $message = \Swift_Message::newInstance() ->setSubject('subject') ->setFrom(array('form')) ->setTo(array('to')) ->setBody('body'); $app['mailer']->send($message); } catch (\Swift_TransportException $e) { $app['logger']->addError('Unable to send welcome email'); } I know it's not going to send any email on localhost and I'm expecting it to fail but why I can't catch the Swift