-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy patherrors.go
38 lines (29 loc) · 1.22 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
package ore
import (
"errors"
"fmt"
"reflect"
)
func noValidImplementation[T any]() error {
return fmt.Errorf("implementation not found for type: %s", reflect.TypeFor[T]())
}
func invalidKeyType(t reflect.Type) error {
return fmt.Errorf("cannot use type: `%s` as a key", t)
}
func nilVal[T any]() error {
return fmt.Errorf("nil implementation for type: %s", reflect.TypeFor[T]())
}
func lifetimeMisalignment(resolver resolverMetadata, depResolver resolverMetadata) error {
return fmt.Errorf("detected lifetime misalignment: %s depends on %s", resolver, depResolver)
}
func cyclicDependency(resolver resolverMetadata) error {
return fmt.Errorf("detected cyclic dependency where: %s depends on itself", resolver)
}
func placeholderValueNotProvided(resolver resolverMetadata) error {
return fmt.Errorf("no value has been provided for this placeholder: %s", resolver)
}
func typeAlreadyRegistered(typeID typeID) error {
return fmt.Errorf("the type '%s' has already been registered (as a Resolver or as a Placeholder). Cannot override it with other Placeholder", typeID)
}
var alreadyBuilt = errors.New("services container is already sealed")
var alreadyBuiltCannotAdd = errors.New("cannot register new resolvers, container is sealed")