fix(curriculum): update custom exception example in Python review (#66102)

This commit is contained in:
Bảo Nguyễn
2026-03-05 16:50:48 +07:00
committed by GitHub
parent b25f03e8a1
commit c646fc6a02
2 changed files with 6 additions and 6 deletions
@@ -99,20 +99,20 @@ dashedName: review-error-handling
return f"Welcome, {username}!"
```
Here's a how you can use the `login` function from the `InvalidCredentialsError` exception:
Here's a how you can use the `login` function with the `InvalidCredentialsError` exception:
```py
# failed login attempt
try:
message = login("user", "wrongpassword")
print(message)
except InvalidCredentialsError as e:
print(f"Login failed: {e}")
else:
print(message)
# successful login attempt
try:
message = login("admin", "password123")
print(message)
except InvalidCredentialsError as e:
# This block is not executed because the login was successful
print(f"Login failed: {e}")
@@ -2041,20 +2041,20 @@ if __name__ == '__main__':
return f"Welcome, {username}!"
```
Here's a how you can use the `login` function from the `InvalidCredentialsError` exception:
Here's a how you can use the `login` function with the `InvalidCredentialsError` exception:
```py
# failed login attempt
try:
message = login("user", "wrongpassword")
print(message)
except InvalidCredentialsError as e:
print(f"Login failed: {e}")
else:
print(message)
# successful login attempt
try:
message = login("admin", "password123")
print(message)
except InvalidCredentialsError as e:
# This block is not executed because the login was successful
print(f"Login failed: {e}")