Skip to content

Commit 5e004c3

Browse files
committed
Sem-Ver: feature Add a handle_retrieval_exception method to the HTTPSMultiRepositoryPublicKeyRetriever class.
Signed-off-by: David Black <[email protected]>
1 parent 964fcee commit 5e004c3

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

atlassian_jwt_auth/key.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -136,14 +136,20 @@ def _create_retrievers(self, key_repository_urls):
136136
return [HTTPSPublicKeyRetriever(url) for url
137137
in key_repository_urls]
138138

139+
def handle_retrieval_exception(self, retriever, exception):
140+
""" Handles working with exceptions encountered during key
141+
retrieval.
142+
"""
143+
if isinstance(exception, PublicKeyRetrieverException):
144+
if exception.status_code is None or exception.status_code < 500:
145+
raise
146+
139147
def retrieve(self, key_identifier, **requests_kwargs):
140148
for retriever in self._retrievers:
141149
try:
142150
return retriever.retrieve(key_identifier, **requests_kwargs)
143151
except (RequestException, PublicKeyRetrieverException) as e:
144-
if isinstance(e, PublicKeyRetrieverException):
145-
if e.status_code is None or e.status_code < 500:
146-
raise
152+
self.handle_retrieval_exception(retriever, e)
147153
logger = logging.getLogger(__name__)
148154
logger.warn('Unable to retrieve public key from store',
149155
extra={'underlying_error': str(e),

0 commit comments

Comments
 (0)