Cdbexception Error Msg

Hi there. I wanna ask if there is a way to handle errors when I have incorrect INSERT into DB. In doc I can read about: but can I use it for DB errors ?

I would like to change this on something else, for example redirect or "sorry m8 try again."