feat: add onError callback for custom error handling#11
Merged
Conversation
Introduces an optional onError callback to the call() method, allowing developers to handle serialization/deserialization errors: - Log errors to external services (Sentry, Datadog, etc.) - Track cache failure metrics - Debug serialization issues in development Key changes: - Added CacheError class with error details (key, type, error, stackTrace, rawData) - Added CacheErrorType enum (serialization, deserializationJson, deserializationFromJson) - Added onError parameter to call() method - Backward compatible: errors still fallback gracefully without callback - Added comprehensive tests - Updated README with documentation Closes #4 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2cd1545 to
ba136d3
Compare
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #11 +/- ##
==========================================
- Coverage 88.80% 86.30% -2.50%
==========================================
Files 3 4 +1
Lines 125 146 +21
==========================================
+ Hits 111 126 +15
- Misses 14 20 +6 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
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 implements the error handler feature as requested in #4, allowing developers to capture and handle serialization/deserialization errors.
Changes
Added
CacheErrorclass with detailed error information:key: The cache key that failedtype: Type of error (serialization, deserializationJson, deserializationFromJson)error: The underlying exceptionstackTrace: Stack trace for debuggingrawData: The data that failed (if available)message: Human-readable error messageAdded
CacheErrorTypeenum to distinguish error typesAdded
onErrorcallback parameter tocall()methodUsage Example
Backward Compatibility
onErroris not provided, existing silent fallback behavior is preservedTest plan
Closes #4
🤖 Generated with Claude Code