Improved error handling code for "table not found"