Skip to content

Commit d81a22d

Browse files
committed
Wrap bulk copy token acquisition with context-specific error handling
1 parent abca6eb commit d81a22d

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

mssql_python/cursor.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2621,7 +2621,13 @@ def _bulkcopy(
26212621
# Fresh token acquisition for mssql-py-core connection
26222622
from mssql_python.auth import AADAuth
26232623

2624-
raw_token = AADAuth.get_raw_token(self.connection._auth_type)
2624+
try:
2625+
raw_token = AADAuth.get_raw_token(self.connection._auth_type)
2626+
except RuntimeError as e:
2627+
raise RuntimeError(
2628+
f"Bulk copy failed: unable to acquire Azure AD token "
2629+
f"for auth_type '{self.connection._auth_type}': {e}"
2630+
) from e
26252631
pycore_context["access_token"] = raw_token
26262632
logger.debug(
26272633
"Bulk copy: acquired fresh Azure AD token for auth_type=%s",

0 commit comments

Comments
 (0)