Handlings database exceptions.