Skip to content

Commit 993addb

Browse files
committed
clean up srv resolver
1 parent 449e03c commit 993addb

File tree

2 files changed

+6
-14
lines changed

2 files changed

+6
-14
lines changed

pymongo/asynchronous/srv_resolver.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,8 @@ def __init__(
9393
try:
9494
split_fqdn = self.__fqdn.split(".")
9595
self.__plist = split_fqdn[1:] if len(split_fqdn) > 2 else split_fqdn
96-
except Exception as exc:
97-
raise ConfigurationError(_INVALID_HOST_MSG % (fqdn,)) from exc
96+
except Exception:
97+
raise ConfigurationError(_INVALID_HOST_MSG % (fqdn,)) from None
9898
self.__slen = len(self.__plist)
9999
self.nparts = len(split_fqdn)
100100

@@ -122,11 +122,7 @@ async def _resolve_uri(self, encapsulate_errors: bool) -> resolver.Answer:
122122
# Raise the original error.
123123
raise
124124
# Else, raise all errors as ConfigurationError.
125-
import traceback
126-
127-
raise ConfigurationError(
128-
traceback.format_exception(type(exc), exc, exc.__traceback__)
129-
) from exc
125+
raise ConfigurationError(str(exc)) from exc
130126
return results
131127

132128
async def _get_srv_response_and_hosts(

pymongo/synchronous/srv_resolver.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,8 @@ def __init__(
9393
try:
9494
split_fqdn = self.__fqdn.split(".")
9595
self.__plist = split_fqdn[1:] if len(split_fqdn) > 2 else split_fqdn
96-
except Exception as exc:
97-
raise ConfigurationError(_INVALID_HOST_MSG % (fqdn,)) from exc
96+
except Exception:
97+
raise ConfigurationError(_INVALID_HOST_MSG % (fqdn,)) from None
9898
self.__slen = len(self.__plist)
9999
self.nparts = len(split_fqdn)
100100

@@ -122,11 +122,7 @@ def _resolve_uri(self, encapsulate_errors: bool) -> resolver.Answer:
122122
# Raise the original error.
123123
raise
124124
# Else, raise all errors as ConfigurationError.
125-
import traceback
126-
127-
raise ConfigurationError(
128-
traceback.format_exception(type(exc), exc, exc.__traceback__)
129-
) from exc
125+
raise ConfigurationError(str(exc)) from exc
130126
return results
131127

132128
def _get_srv_response_and_hosts(

0 commit comments

Comments
 (0)