Files
main/rules-v0/cursorrules-file-cursor-ai-python-fastapi-api/error-handling-priorities.mdc
T
2025-02-27 00:04:07 +05:30

12 lines
676 B
Plaintext

---
description: Emphasizes the importance of prioritizing error handling and edge cases in Python code.
globs: **/*.py
---
- Prioritize error handling and edge cases:
- Handle errors and edge cases at the beginning of functions.
- Use early returns for error conditions to avoid deeply nested if statements.
- Place the happy path last in the function for improved readability.
- Avoid unnecessary else statements; use the if-return pattern instead.
- Use guard clauses to handle preconditions and invalid states early.
- Implement proper error logging and user-friendly error messages.
- Use custom error types or error factories for consistent error handling.