Error handling and logging.