error handling on tables and flow to file