Catch exceptions in db thread.