modifing error table and write to database