8.4.2 How to catch Doctrine exception in single page controller

Permalink
A single page controller's
public function validate($args)

catches php post errors.

How can I catch DB exceptions thrown by Doctrine? For example I have a unique key:
/**
     * @ORM\Column(type="string",unique=true)
     */
    protected $uid;

when I save the same uid it throws a DB exception. How can I catch it in the controller?

linuxoid
 
JohntheFish replied on at Permalink Reply
JohntheFish
If providing an ID (as opposed to letting the database provide an incremented id), you should be ensuring the ID is unique before saving, not letting it fail and picking up the pieces later.