-
Notifications
You must be signed in to change notification settings - Fork 102
feat: introduce CopyError
to identify error source in copy operations
#933
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
Signed-off-by: Lixia (Sylvia) Lei <lixlei@microsoft.com>
Signed-off-by: Lixia (Sylvia) Lei <lixlei@microsoft.com>
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #933 +/- ##
==========================================
+ Coverage 81.25% 81.69% +0.44%
==========================================
Files 63 64 +1
Lines 6076 6119 +43
==========================================
+ Hits 4937 4999 +62
+ Misses 801 790 -11
+ Partials 338 330 -8 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Signed-off-by: Lixia (Sylvia) Lei <lixlei@microsoft.com>
Signed-off-by: Lixia (Sylvia) Lei <lixlei@microsoft.com>
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 PR introduces a new error type, CopyError, to better indicate error origins in copy operations by wrapping errors with additional context. Key changes include:
- Replacing plain error messages with structured CopyError instances across copy and extended copy functions.
- Updating test cases to assert error types and origins using errors.Is and type assertions.
- Adding dedicated tests and examples for CopyError behavior.
Reviewed Changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 1 comment.
Show a summary per file
File | Description |
---|---|
internal/platform/platform_test.go | Updated error assertions to use errors.Is |
internal/platform/platform.go | Wrapped error with errdef.ErrUnsupported using error wrapping |
extendedcopy_test.go | Modified tests to check for CopyError and correct origins |
extendedcopy.go | Updated error handling in ExtendedCopy functions |
example_copyerror_test.go | Added an example demonstrating CopyError usage |
copyerror_test.go | Added tests for CopyError creation and behavior |
copyerror.go | Introduced the new CopyError type and its helper function |
copy_test.go | Updated copy tests to assert new error wrapping |
copy.go | Updated Copy and helper functions to use newCopyError |
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 PR introduces a new error type, CopyError, to provide more precise identification of error sources during copy operations. Key changes include:
- Wrapping error returns with newCopyError to incorporate error origin (source, destination, internal).
- Updating error expectations in tests to use errors.Is comparisons.
- Adding tests and examples to verify and demonstrate the CopyError functionality.
Reviewed Changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 1 comment.
Show a summary per file
File | Description |
---|---|
internal/platform/*.go | Updated error handling to wrap errors with CopyError for unsupported configuration cases. |
extendedcopy_test.go | Renamed test function and updated error assertions to verify CopyError usage. |
extendedcopy.go | Modified error returns to use newCopyError, ensuring consistent error wrapping. |
example_copyerror_test.go | Added an example demonstrating how to inspect CopyError fields. |
copyerror*.go and copy_test.go | Created and tested CopyError implementation with comprehensive unit tests. |
copy.go | Refactored error handling in copy operations to use CopyError for designated error origins. |
Signed-off-by: Lixia (Sylvia) Lei <lixlei@microsoft.com>
Signed-off-by: Lixia (Sylvia) Lei <lixlei@microsoft.com>
Signed-off-by: Lixia (Sylvia) Lei <lixlei@microsoft.com>
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.
Copilot reviewed 9 out of 9 changed files in this pull request and generated no comments.
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.
Copilot reviewed 10 out of 10 changed files in this pull request and generated 1 comment.
Signed-off-by: Lixia (Sylvia) Lei <lixlei@microsoft.com>
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.
Copilot reviewed 10 out of 10 changed files in this pull request and generated 1 comment.
Comments suppressed due to low confidence (1)
copy.go:273
- [nitpick] Consider using newCopyError instead of fmt.Errorf here for consistent error wrapping and to preserve error origin information.
return fmt.Errorf("failed to check cache existence: %s: %w", desc.Digest, err)
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.
LGTM with suggestions
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.
LGTM
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.
LGTM
CopyError
and return it fromCopy
andExtendedCopy
when necessaryCopyError
typeResolve #677