Improved error handling for the anomaly detector