1// Package commonerr contains common errors between different Praefect components. Ideally
2// this package's contents would be in praefect's root package but this is not possible at the moment
3// due to cyclic imports.
4package commonerr
5
6import (
7	"errors"
8	"fmt"
9)
10
11// RepositoryNotFoundError is returned when attempting to operate on a repository
12// that does not exist in the virtual storage.
13type RepositoryNotFoundError struct {
14	virtualStorage string
15	relativePath   string
16}
17
18// NewRepositoryNotFoundError returns a new repository not found error for the given repository.
19func NewRepositoryNotFoundError(virtualStorage string, relativePath string) error {
20	return RepositoryNotFoundError{virtualStorage: virtualStorage, relativePath: relativePath}
21}
22
23// Error returns the error message.
24func (err RepositoryNotFoundError) Error() string {
25	return fmt.Sprintf("repository %q/%q not found", err.virtualStorage, err.relativePath)
26}
27
28// ErrRepositoryAlreadyExists is returned when attempting to create a repository that already exists.
29var ErrRepositoryAlreadyExists = errors.New("repository already exists")
30