-
Notifications
You must be signed in to change notification settings - Fork 0
refactor: standardize application layer error handling and user feedback across modules #720
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…in fetchDayDiet - fetchDayDiet now throws on error or not found, never returns null - uses handleApiError and handleValidationError with context - updated JSDoc for exported function - all checks and tests passed
…upabaseFoodRepository - fetchFoodById, fetchFoodByEan, insertFood, upsertFood now throw on error or not found, never return null - use handleApiError with context for all error cases - updated JSDoc for all exported functions - all checks and tests passed
… supabaseRecipeRepository - All exported functions now throw on error or not found, never return null - All error cases use handleApiError with context - Updated JSDoc for all exported functions - All checks and tests passed
…ProfileRepository - All exported functions now throw errors instead of returning null - Use handleApiError for API/validation errors - Add and update JSDoc for all exported functions - Remove all null returns for error cases - Ensure code passes lint, type-check, and tests
… toast display - Adiciona try/catch em todos os parseWithStack/map(createRecipeFromDAO) - Chama handleValidationError para erros de validação de schema - Garante que erros de validação apareçam corretamente no toast - Passa lint, type-check e testes
…ience and never throw to UI
- Usa showPromise com { context, audience } em todas as operações
- Nunca propaga erro para a UI, sempre retorna valor seguro
- Garante tratamento consistente de erros com handleApiError
- Passa lint, type-check e testes
…n application layer
… in application layer
…in application layer
…in application layer
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This pull request standardizes error handling and user feedback across multiple modules by consistently using handleApiError and showPromise. Key changes include updating application layer functions in user, food, recipe, day-diet, and macro-profile modules, as well as adding detailed documentation for the error handling plan.
Reviewed Changes
Copilot reviewed 15 out of 15 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| src/sections/item-group/components/GroupHeaderActions.tsx | Adds a check to handle missing insertedRecipe with a UI error message. |
| src/modules/user/application/user.ts | Updates fetch, insert, update, and delete operations to return explicit boolean or null values and use showPromise. |
| src/modules/search/application/searchCache.ts | Standardizes return values for caching functions with error handling via handleApiError. |
| src/modules/recent-food/application/recentFood.ts | Wraps recent food operations in showPromise and improves error reporting. |
| src/modules/measure/application/measure.ts | Updates measure functions to return null/boolean on errors with standardized error handling. |
| src/modules/diet/recipe/infrastructure/supabaseRecipeRepository.ts | Refactors recipe repository functions to include validation error handling and consistent error feedback. |
| src/modules/diet/recipe/application/recipe.ts | Applies showPromise to user recipe functions for improved UI feedback. |
| src/modules/diet/meal/application/meal.ts | Updates meal update functions to return boolean instead of throwing errors. |
| src/modules/diet/macro-profile/infrastructure/supabaseMacroProfileRepository.ts | Standardizes macro profile operations with detailed error and validation handling. |
| src/modules/diet/macro-profile/application/macroProfile.ts | Adjusts macro profile functions to return explicit values on failure and use showPromise. |
| src/modules/diet/item-group/domain/itemGroup.ts | Updates the schema by removing the non-empty constraint from items. |
| src/modules/diet/food/infrastructure/supabaseFoodRepository.ts | Refactors food repository functions with upsert and detailed error handling. |
| src/modules/diet/food/application/food.ts | Enhances food search functions and integrates caching logic with improved error reporting. |
| src/modules/diet/day-diet/infrastructure/supabaseDayRepository.ts | Improves fetching a day diet with detailed error and validation handling. |
| src/modules/diet/day-diet/application/dayDiet.ts | Adjusts day diet operations to return a boolean result and updates error handling accordingly. |
Comments suppressed due to low confidence (2)
src/modules/diet/day-diet/application/dayDiet.ts:140
- The return type for updateDayDiet has changed from void to boolean. Verify that all consumers of this function have been updated to handle its new boolean return value.
): Promise<boolean> {
src/modules/diet/day-diet/infrastructure/supabaseDayRepository.ts:69
- The function calls handleValidationError but the file does not import it. Please add an appropriate import for handleValidationError to ensure proper error reporting.
handleValidationError('DayDiet not found', {
This PR standardizes error handling and user feedback in the application layer for multiple modules, including user, search-cache, day-diet, meal, food, macro-profile, recent-food, measure, recipe, and item-group. All application layer orchestrations now consistently use
handleApiErrorwith context, and UI feedback is unified viashowPromisewhere appropriate. Domain logic is kept pure, and error throwing is enforced in repositories. Validation and error propagation are improved, especially in recipe and food modules. The PR also includes a new documentation file outlining the application layer error handling plan.Notable changes:
handleApiErrorwith context.handleApiError.showPromise.docs/application-layer-error-handling-plan.md.closes #307