Use specific exception types and avoid masking errors through overly broad exception handling or default values. This improves error diagnosis and system reliability.
Use specific exception types and avoid masking errors through overly broad exception handling or default values. This improves error diagnosis and system reliability.
Key guidelines:
Example - Instead of:
try:
result = client.refresh_token(token)
except Exception as e:
log.error("Error refreshing token: %s", e)
return None
Use:
def refresh_token(self, refresh_token: str) -> str:
"""Refresh the access token for the user."""
client = self._get_keycloak_client()
tokens = client.refresh_token(refresh_token)
log.info("Token refreshed successfully")
return tokens["access_token"]
This approach:
Enter the URL of a public GitHub repository