From c0d82d86246c1bb5bfe8c06534234a6f28984921 Mon Sep 17 00:00:00 2001 From: Alex Tremblay Date: Tue, 27 May 2025 17:45:16 -0400 Subject: [PATCH] add matched error message to ConfigInvalidException message --- netmiko/base_connection.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) 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: