feat: Add comprehensive error handling module with custom exceptions#106
Open
xingzihai wants to merge 3 commits intomvanhorn:mainfrom
Open
feat: Add comprehensive error handling module with custom exceptions#106xingzihai wants to merge 3 commits intomvanhorn:mainfrom
xingzihai wants to merge 3 commits intomvanhorn:mainfrom
Conversation
- Add centralized path configuration in env.py with XDG-compliant defaults - Support environment variable overrides for all paths: - LAST30DAYS_CONFIG_DIR for config directory - LAST30DAYS_DATA_DIR for data directory - LAST30DAYS_DATABASE_PATH for database file - LAST30DAYS_CACHE_DIR for cache directory - LAST30DAYS_OUTPUT_DIR for output directory - LAST30DAYS_BRIEFS_DIR for briefs directory - Update all modules to use centralized path functions - Update UI to dynamically show actual config paths - Add fallback to temp directories when permission denied - Update README.md with path customization documentation This allows users to customize storage locations for different deployment environments (containers, shared systems, etc.)
This PR adds extensive test coverage for: **Score Module (test_score_comprehensive.py):** - All engagement calculation functions (Reddit, X, YouTube, TikTok, Instagram, HN, Bluesky, TruthSocial, Polymarket) - Edge cases for log1p_safe utility function - Detailed tests for normalize_to_100 with edge cases - Scoring functions for all item types including YouTube, TikTok, Instagram, Polymarket - WebSearch scoring with query type awareness - Sort order with query-type-aware tiebreakers - Date confidence penalties - Unknown engagement penalties **Normalize Module (test_normalize_comprehensive.py):** - Comprehensive tests for all item types (Reddit, X, YouTube, TikTok, Instagram, HN, Bluesky, TruthSocial, Polymarket) - Date filtering edge cases including boundary dates and None dates - Items_to_dicts conversion for all item types - Engagement parsing for different platforms - Cross-type normalization consistency tests Total: 92 new tests added
Adds unified error handling with: - Custom exception hierarchy (APIError, RateLimitError, TimeoutError, etc.) - ErrorContext for rich debugging information - @with_retry decorator with exponential backoff - ErrorAggregator for parallel operations - Comprehensive test suite (43 tests)
xingzihai
added a commit
to xingzihai/last30days-skill
that referenced
this pull request
Mar 26, 2026
The query 'nano banana pro prompting' was tested in both test_product_queries and test_howto_queries with conflicting expectations. Since 'prompting' matches _HOWTO_PATTERNS before _PRODUCT_PATTERNS due to priority order, the correct result is 'how_to'. Removed the incorrect assertion from test_product_queries. This is a pre-existing test bug (from PR mvanhorn#65), not introduced by PR mvanhorn#106.
Owner
|
See my reply on #109 covering all your PRs. Can't commit to anything right now with the v3.0 refactor underway, but I promise I'll consider each one once it lands. Appreciate the work. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR adds a unified error handling module (
scripts/lib/errors.py) that significantly improves error handling and logging capabilities across the last30days-skill project.Changes
1. Custom Exception Hierarchy
A structured exception hierarchy with the following types:
Last30DaysError: Base exception for all project errorsNetworkError: Network-level errors (DNS, connection refused)APIError: External API errors with status code and response bodyRateLimitError: Rate limiting errors (HTTP 429) with retry_after supportTimeoutError: Operation timeout errorsAuthError: Authentication/authorization errorsConfigError: Configuration errorsValidationError: Input validation errorsParsingError: Data parsing errorsDependencyError: Missing dependency errors with install instructionsSourceUnavailableError: Data source unavailability errors2. Rich Error Context
ErrorContextdataclass for structured debugging informationErrorSeverityenum (LOW, MEDIUM, HIGH, FATAL)ErrorCategoryenum for error classification3. Retry Mechanism
@with_retrydecorator with exponential backoffRateLimitError.retry_afterto respect API rate limits4. Utility Functions
ErrorAggregatorfor collecting multiple errors in parallel operationswrap_exception()to convert generic exceptions to Last30DaysErrorsafe_call()for safe function execution with fallbackhttp_error_to_last30days()to bridge existing http.HTTPError5. Comprehensive Test Suite
Testing
All 43 tests pass:
Benefits