Error handler for cron and api