Fixed catching database exceptions