Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

add error type return by oras.Copy #677

Open
qweeah opened this issue Jan 11, 2024 · 0 comments
Open

add error type return by oras.Copy #677

qweeah opened this issue Jan 11, 2024 · 0 comments
Assignees
Labels
enhancement New feature or request
Milestone

Comments

@qweeah
Copy link
Contributor

qweeah commented Jan 11, 2024

Background
oras.Copy is consisted of several different operations. To add more context to the returned error, current implementation is to wrap a description string over the error, e.g. when resolving the source artifact fails, below string will be added to wrap the original error:

oras-go/copy.go

Line 138 in f296072

return ocispec.Descriptor{}, fmt.Errorf("failed to resolve %s: %w", srcRef, err)

Problem
This method imposes below challenges when processing the obtained error:

  1. string context are hard to process: taking the above error as an example, it's hard to extract out the added context failed to resolve $srcRef out elegantly from caller side
  2. lack information of where the error happens: an error might happens on source target or destination target, it's not reflected in the added context

Solution
Adding a structured error type for error returned by oras.Copy like below

type CopyError struct {
    // represents the failing operation, e.g. resolve
    Op string 
    // represents where it fails
    On string // enumerable string, source or dest
    // Inner error
    Err error
}
@qweeah qweeah changed the title add error type for oras.Copy add error type return by oras.Copy Jan 11, 2024
@yizha1 yizha1 added this to the v2.5.0 milestone Jan 16, 2024
@yizha1 yizha1 added the enhancement New feature or request label Jan 16, 2024
@shizhMSFT shizhMSFT modified the milestones: v2.5.0, v2.6.0 Mar 12, 2024
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants