Added automatic exception logging to database