Added error handling for the log_excerpt method