-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy patherrors.go
36 lines (30 loc) · 890 Bytes
/
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
package di
import (
"errors"
"fmt"
)
var (
// ErrTypeNotExists causes when type not found in container.
ErrTypeNotExists = errors.New("not exists in the container")
)
var (
errInvalidInvocationSignature = errors.New("invalid invocation signature")
errCycleDetected = errors.New("cycle detected")
errFieldsNotSupported = errors.New("fields not supported")
)
// knownError return true if err is library known error.
func knownError(err error) bool {
if errors.Is(err, ErrTypeNotExists) ||
errors.Is(err, errInvalidInvocationSignature) ||
errors.Is(err, errCycleDetected) ||
errors.Is(err, errFieldsNotSupported) {
return true
}
return false
}
func errWithStack(err error) error {
return fmt.Errorf("%s: %w", stacktrace(1), err)
}
func bug() {
panic("you found a bug, please create new issue for this: https://github.com/defval/di/issues/new")
}