return err == fs.ErrNotExist
}
+// ErrUnsupported indicates that a requested operation cannot be performed,
+// because it is unsupported. This error indicates that there is no alternative
+// way to perform the operation.
+//
+// TODO(#41198): Remove this declaration and use errors.ErrUnsupported instead.
+var ErrUnsupported = unsupportedOperationError{}
+
+type unsupportedOperationError struct{}
+
+func (unsupportedOperationError) Error() string {
+ return "unsupported operation"
+}
+
// AllHex reports whether the revision rev is entirely lower-case hexadecimal digits.
func AllHex(rev string) bool {
for i := 0; i < len(rev); i++ {
func (e *VCSError) Error() string { return e.Err.Error() }
+func (e *VCSError) Unwrap() error { return e.Err }
+
func vcsErrorf(format string, a ...any) error {
return &VCSError{Err: fmt.Errorf(format, a...)}
}
}
}
-var ErrNoRepoHash = errors.New("RepoHash not supported")
-
func (r *vcsRepo) CheckReuse(old *Origin, subdir string) error {
- return fmt.Errorf("vcs %s does not implement CheckReuse", r.cmd.vcs)
+ return fmt.Errorf("vcs %s: CheckReuse: %w", r.cmd.vcs, ErrUnsupported)
}
func (r *vcsRepo) Tags(prefix string) (*Tags, error) {
}
defer unlock()
- return "", vcsErrorf("RecentTag not implemented")
+ return "", vcsErrorf("vcs %s: RecentTag: %w", r.cmd.vcs, ErrUnsupported)
}
func (r *vcsRepo) DescendsFrom(rev, tag string) (bool, error) {
}
defer unlock()
- return false, vcsErrorf("DescendsFrom not implemented")
+ return false, vcsErrorf("vcs %s: DescendsFrom: %w", r.cmd.vcs, ErrUnsupported)
}
func (r *vcsRepo) ReadZip(rev, subdir string, maxSize int64) (zip io.ReadCloser, err error) {
if r.cmd.readZip == nil && r.cmd.doReadZip == nil {
- return nil, vcsErrorf("ReadZip not implemented for %s", r.cmd.vcs)
+ return nil, vcsErrorf("vcs %s: ReadZip: %w", r.cmd.vcs, ErrUnsupported)
}
unlock, err := r.mu.Lock()