diff --git a/netmiko/base_connection.py b/netmiko/base_connection.py index 690a6c72d..9f7bf5deb 100644 --- a/netmiko/base_connection.py +++ b/netmiko/base_connection.py @@ -2343,8 +2343,10 @@ def send_config_set( ) if error_pattern: - if re.search(error_pattern, output, flags=re.M): - msg = f"Invalid input detected at command: {cmd}" + error_match = re.search(error_pattern, output, flags=re.M) + if error_match: + error_msg = error_match.group(0) + msg = f"Invalid input detected at command: {cmd}, matched error: {error_msg}" raise ConfigInvalidException(msg) if exit_config_mode: