| 1 | /* |
| 2 | Copyright The ORAS Authors. |
| 3 | Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | you may not use this file except in compliance with the License. |
| 5 | You may obtain a copy of the License at |
| 6 | |
| 7 | http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | |
| 9 | Unless required by applicable law or agreed to in writing, software |
| 10 | distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | See the License for the specific language governing permissions and |
| 13 | limitations under the License. |
| 14 | */ |
| 15 | |
| 16 | package orasscip-go gomod oras.land/oras-go/v2 . `oras.land/oras-go/v2`/ |
| 17 | |
| 18 | import "fmtscip-go gomod github.com/golang/go/src go1.23.0 fmt/" |
| 19 | |
| 20 | // CopyErrorOrigin defines the source of a copy error. |
| 21 | type CopyErrorOriginscip-go gomod oras.land/oras-go/v2 . `oras.land/oras-go/v2`/CopyErrorOrigin# int |
| 22 | |
| 23 | const ( |
| 24 | // CopyErrorOriginSource indicates the error occurred at the source side. |
| 25 | CopyErrorOriginSourcescip-go gomod oras.land/oras-go/v2 . `oras.land/oras-go/v2`/CopyErrorOriginSource. CopyErrorOriginscip-go gomod oras.land/oras-go/v2 . `oras.land/oras-go/v2`/CopyErrorOrigin# = 1 |
| 26 | |
| 27 | // CopyErrorOriginDestination indicates the error occurred at the destination side. |
| 28 | CopyErrorOriginDestinationscip-go gomod oras.land/oras-go/v2 . `oras.land/oras-go/v2`/CopyErrorOriginDestination. CopyErrorOriginscip-go gomod oras.land/oras-go/v2 . `oras.land/oras-go/v2`/CopyErrorOrigin# = 2 |
| 29 | ) |
| 30 | |
| 31 | // String returns the string representation of the CopyErrorOrigin. |
| 32 | func (o CopyErrorOriginscip-go gomod oras.land/oras-go/v2 . `oras.land/oras-go/v2`/CopyErrorOrigin#) Stringscip-go gomod oras.land/oras-go/v2 . `oras.land/oras-go/v2`/CopyErrorOrigin#String().() string { |
| 33 | switch o { |
| 34 | case CopyErrorOriginSourcescip-go gomod oras.land/oras-go/v2 . `oras.land/oras-go/v2`/CopyErrorOriginSource.: |
| 35 | return "source" |
| 36 | case CopyErrorOriginDestinationscip-go gomod oras.land/oras-go/v2 . `oras.land/oras-go/v2`/CopyErrorOriginDestination.: |
| 37 | return "destination" |
| 38 | default: |
| 39 | return "unknown" |
| 40 | } |
| 41 | } |
| 42 | |
| 43 | // CopyError represents an error encountered during a copy operation. |
| 44 | type CopyErrorscip-go gomod oras.land/oras-go/v2 . `oras.land/oras-go/v2`/CopyError# struct { |
| 45 | // Op is the operation that caused the error. |
| 46 | Opscip-go gomod oras.land/oras-go/v2 . `oras.land/oras-go/v2`/CopyError#Op. string |
| 47 | // Origin indicates the source of the error. |
| 48 | Originscip-go gomod oras.land/oras-go/v2 . `oras.land/oras-go/v2`/CopyError#Origin. CopyErrorOriginscip-go gomod oras.land/oras-go/v2 . `oras.land/oras-go/v2`/CopyErrorOrigin# |
| 49 | // Err is the underlying error. |
| 50 | Errscip-go gomod oras.land/oras-go/v2 . `oras.land/oras-go/v2`/CopyError#Err. error |
| 51 | } |
| 52 | |
| 53 | // newCopyError creates a new CopyError. |
| 54 | func newCopyErrorscip-go gomod oras.land/oras-go/v2 . `oras.land/oras-go/v2`/newCopyError().(op string, origin CopyErrorOriginscip-go gomod oras.land/oras-go/v2 . `oras.land/oras-go/v2`/CopyErrorOrigin#, err error) error { |
| 55 | if err == nil { |
| 56 | return nil |
| 57 | } |
| 58 | return &CopyErrorscip-go gomod oras.land/oras-go/v2 . `oras.land/oras-go/v2`/CopyError#{ |
| 59 | Opscip-go gomod oras.land/oras-go/v2 . `oras.land/oras-go/v2`/CopyError#Op.: op, |
| 60 | Originscip-go gomod oras.land/oras-go/v2 . `oras.land/oras-go/v2`/CopyError#Origin.: origin, |
| 61 | Errscip-go gomod oras.land/oras-go/v2 . `oras.land/oras-go/v2`/CopyError#Err.: err, |
| 62 | } |
| 63 | } |
| 64 | |
| 65 | // Error implements the error interface for CopyError. |
| 66 | func (e *CopyErrorscip-go gomod oras.land/oras-go/v2 . `oras.land/oras-go/v2`/CopyError#) Errorscip-go gomod oras.land/oras-go/v2 . `oras.land/oras-go/v2`/CopyError#Error().() string { |
| 67 | switch e.Originscip-go gomod oras.land/oras-go/v2 . `oras.land/oras-go/v2`/CopyError#Origin. { |
| 68 | case CopyErrorOriginSourcescip-go gomod oras.land/oras-go/v2 . `oras.land/oras-go/v2`/CopyErrorOriginSource., CopyErrorOriginDestinationscip-go gomod oras.land/oras-go/v2 . `oras.land/oras-go/v2`/CopyErrorOriginDestination.: |
| 69 | return fmtscip-go gomod github.com/golang/go/src go1.23.0 fmt/.Sprintfscip-go gomod github.com/golang/go/src go1.23.0 fmt/Sprintf().("failed to perform %q on %s: %v", e.Opscip-go gomod oras.land/oras-go/v2 . `oras.land/oras-go/v2`/CopyError#Op., e.Originscip-go gomod oras.land/oras-go/v2 . `oras.land/oras-go/v2`/CopyError#Origin., e.Errscip-go gomod oras.land/oras-go/v2 . `oras.land/oras-go/v2`/CopyError#Err.) |
| 70 | default: |
| 71 | return fmtscip-go gomod github.com/golang/go/src go1.23.0 fmt/.Sprintfscip-go gomod github.com/golang/go/src go1.23.0 fmt/Sprintf().("failed to perform %q: %v", e.Opscip-go gomod oras.land/oras-go/v2 . `oras.land/oras-go/v2`/CopyError#Op., e.Errscip-go gomod oras.land/oras-go/v2 . `oras.land/oras-go/v2`/CopyError#Err.) |
| 72 | } |
| 73 | } |
| 74 | |
| 75 | // Unwrap implements the errors.Unwrap interface for CopyError. |
| 76 | func (e *CopyErrorscip-go gomod oras.land/oras-go/v2 . `oras.land/oras-go/v2`/CopyError#) Unwrapscip-go gomod oras.land/oras-go/v2 . `oras.land/oras-go/v2`/CopyError#Unwrap().() error { |
| 77 | return e.Errscip-go gomod oras.land/oras-go/v2 . `oras.land/oras-go/v2`/CopyError#Err. |
| 78 | } |