13. Secure Use of Exceptions
Exceptions are helpful but can leak sensitive data if mishandled.
Insecure Example
try:
1 / 0
except Exception as e:
print("Error:", e) # Reveals system info
Secure Example
try:
1 / 0
except ZeroDivisionError:
print("Cannot divide by zero.")
✅ Lesson: Catch specific exceptions. Avoid dumping stack traces to users.