Doctrine automatically sets ERRMODE to exception, however you must catch \Doctrine\DBAL\DBALException, as PDOException is wrapped inside (as pevious exception).
On Thu, Jul 30, 2015 at 11:59 AM, Thomas Baumann <[email protected]> wrote: > Hmm, that should work out of the box, I guess. When something is wrong on > my side, a null constraint violation for instance, I get > a Doctrine\DBAL\Exception\NotNullConstraintViolationException, which > precedes a Doctrine\DBAL\Driver\PDOException, which in turn precedes a > \PDOException. > > > On Thursday, July 30, 2015 at 10:52:12 AM UTC+2, Raffaello Bertini wrote: >> >> Anyway it is required to use the setAttribute PDO:ATTR_ERRMODO, >> PDO::ERRMODE_EXCEPTION for the PDOException to be caught? >> if it is the case how can do it with doctrine2? >> >> On Thursday, July 30, 2015 at 9:51:13 AM UTC+1, Raffaello Bertini wrote: >>> >>> oh man, the typo is in this post not on the code. if I had a typo the >>> code would be interpreted. and the error is not a FatalError uncaught >>> exception. >>> >>> On Thursday, July 30, 2015 at 9:47:59 AM UTC+1, Parsifal wrote: >>>> >>>> Because you have typo: >>>> >>>> } catch{\PDOException $e) { >>>> >>>> It must be >>>> } catch (\PDOException $e) { >>>> >>>> You are using { instead of ( >>>> >>> -- > You received this message because you are subscribed to the Google Groups > "doctrine-user" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To post to this group, send email to [email protected]. > Visit this group at http://groups.google.com/group/doctrine-user. > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "doctrine-user" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/doctrine-user. For more options, visit https://groups.google.com/d/optout.
