mirror of
https://github.com/sanjeed5/awesome-cursor-rules-mdc.git
synced 2026-11-30 23:04:59 +08:00
add .mdc file
This commit is contained in:
@@ -0,0 +1,14 @@
|
||||
---
|
||||
description: Guidelines for handling errors and edge cases in Python and FastAPI applications.
|
||||
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.
|
||||
- Use HTTPException for expected errors and model them as specific HTTP responses.
|
||||
- Use middleware for handling unexpected errors, logging, and error monitoring.
|
||||
Reference in New Issue
Block a user