Skip to content

Commit 3246adf

Browse files
authored
Update netbox_export.py
Refactor Netbox connection handling and improve error logging
1 parent 45424d1 commit 3246adf

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

netbox_export.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -193,9 +193,13 @@ def main() -> None:
193193
url, token = load_config()
194194

195195
# Connect to Netbox
196-
logger.info("Connecting to Netbox...")
197-
netbox_instance = netbox_connection.connect_to_netbox(url, token)
198-
logger.info("Successfully connected to Netbox")
196+
try:
197+
logger.info("Connecting to Netbox...")
198+
netbox_instance = netbox_connection.connect_to_netbox(url, token)
199+
logger.info("Successfully connected to Netbox")
200+
except Exception as e:
201+
logger.error("Failed to connect to Netbox", exc_info=True)
202+
raise
199203

200204
# Retrieve and export data
201205
ipam_prefixes = get_ipam_prefixes(netbox_instance)

0 commit comments

Comments
 (0)