error-handling-patterns
Use when adding error handling - exception patterns, HTTP codes, domain exceptions
التثبيت باستخدام Codex أو Claude انسخ هذا Prompt والصقه في Codex أو Claude أو مساعد آخر ليراجع صفحة Skill ويثبّتها لك.
القائمة
Use when adding error handling - exception patterns, HTTP codes, domain exceptions
التثبيت باستخدام Codex أو Claude انسخ هذا Prompt والصقه في Codex أو Claude أو مساعد آخر ليراجع صفحة Skill ويثبّتها لك.
استنادا إلى تصنيف SOC المهني
Master code organization - encapsulation with wrapper methods, file modularity (split >150 lines), one function one responsibility, descriptive naming, minimal comments
Use when starting work - guidelines for asking questions and commit policies
Use when adding logging to features - structured logging with LoggerService categories
Use when exiting plan mode - where to save implementation plans
Apply Martin Fowler's refactoring patterns - extract variables to eliminate repetition, split temporary variables, replace temp with query for cleaner, more maintainable code
Use when writing tests - test structure, mocking patterns, pre-commit checks
| name | error-handling-patterns |
| description | Use when adding error handling - exception patterns, HTTP codes, domain exceptions |
Use this skill when implementing error handling for features or API endpoints.
except - always specify exception typeclass ModelNotFoundError(ValueError):
"""Raised when a requested model is not found."""
pass
class InsufficientMemoryError(RuntimeError):
"""Raised when GPU memory is insufficient for operation."""
pass
Use the correct status code for each situation:
from app.services import logger_service
from app.schemas.responses import ErrorResponse, SuccessResponse
logger = logger_service.get_logger(__name__, category='API')
async def generate_image(config: GenerateConfig, db: Session):
try:
result = await service.generate_image(config, db)
return SuccessResponse(data=result)
except ValueError as error:
logger.error(f"Generation failed: {error}")
raise HTTPException(status_code=400, detail=str(error))
except torch.cuda.OutOfMemoryError:
logger.error("Out of GPU memory")
raise HTTPException(status_code=500, detail="Insufficient GPU memory")
except Exception as error:
logger.exception(f"Unexpected error: {error}")
raise HTTPException(status_code=500, detail="Internal server error")
except:)