Error handling and security