-
Notifications
You must be signed in to change notification settings - Fork 367
/
Copy patherrors.go
77 lines (66 loc) · 2.93 KB
/
errors.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
package graveler
import (
"errors"
"fmt"
"github.com/treeverse/lakefs/pkg/db"
)
var (
// Base error for "user-visible" errors, which should not be wrapped with internal
// debug info.
ErrUserVisible = errors.New("")
// TODO(ariels): Wrap with ErrUserVisible once db is gone.
ErrNotFound = wrapError(db.ErrNotFound, "not found")
ErrNotUnique = errors.New("not unique")
ErrPreconditionFailed = errors.New("precondition failed")
ErrInvalidValue = errors.New("invalid value")
ErrInvalidMergeBase = fmt.Errorf("only 2 commits allowed in FindMergeBase: %w", ErrInvalidValue)
ErrNoMergeBase = errors.New("no merge base")
ErrInvalidRef = fmt.Errorf("ref: %w", ErrInvalidValue)
ErrInvalidCommitID = fmt.Errorf("commit id: %w", ErrInvalidValue)
ErrCommitNotFound = fmt.Errorf("commit %w", ErrNotFound)
ErrCreateBranchNoCommit = fmt.Errorf("can't create a branch without commit")
ErrRepositoryNotFound = fmt.Errorf("repository %w", ErrNotFound)
ErrBranchNotFound = fmt.Errorf("branch %w", ErrNotFound)
ErrTagNotFound = fmt.Errorf("tag %w", ErrNotFound)
ErrRefAmbiguous = fmt.Errorf("reference is ambiguous: %w", ErrNotFound)
ErrNoChanges = wrapError(ErrUserVisible, "no changes")
ErrConflictFound = errors.New("conflict found")
ErrCommitNotHeadBranch = errors.New("commit is not head of branch")
ErrBranchExists = fmt.Errorf("branch already exists: %w", ErrNotUnique)
ErrTagAlreadyExists = fmt.Errorf("tag already exists: %w", ErrNotUnique)
ErrDirtyBranch = errors.New("can't apply meta-range on dirty branch")
ErrMetaRangeNotFound = errors.New("metarange not found")
ErrLockNotAcquired = errors.New("lock not acquired")
ErrRevertMergeNoParent = errors.New("must specify 1-based parent number for reverting merge commit")
ErrAddCommitNoParent = errors.New("added commit must have a parent")
ErrMultipleParents = errors.New("cannot have more than a single parent")
ErrRevertParentOutOfRange = errors.New("given commit does not have the given parent number")
)
// wrappedError is an error for wrapping another error while ignoring its message.
type wrappedError struct {
err error
msg string
}
func (w *wrappedError) Error() string {
return w.msg
}
func (w *wrappedError) Unwrap() error {
return w.err
}
// wrapError returns an error wrapping err with message msg, ignoring the error message from
// err.
func wrapError(err error, msg string) error {
return &wrappedError{err: err, msg: msg}
}
// HookAbortError abort by hook error, holds the event type with the run id to trace back the run
type HookAbortError struct {
EventType EventType
RunID string
Err error
}
func (e *HookAbortError) Error() string {
return fmt.Sprintf("%s hook aborted, run id '%s': %s", e.EventType, e.RunID, e.Err)
}
func (e *HookAbortError) Unwrap() error {
return e.Err
}