-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patherrors.go
More file actions
44 lines (36 loc) · 801 Bytes
/
errors.go
File metadata and controls
44 lines (36 loc) · 801 Bytes
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
package assemble
import (
"errors"
"fmt"
"reflect"
)
var (
ErrBindingNotFound = errors.New("binding not found")
ErrInvokeFail = errors.New("invoke failed")
)
type BadCastError struct {
Key Key
From reflect.Type
To reflect.Type
}
func (e BadCastError) Error() string {
return fmt.Sprintf("bad cast %v -> %v for %v", e.From, e.To, e.Key)
}
type NotFoundError struct {
Type reflect.Type
Name string
}
func (e NotFoundError) Error() string {
if e.Name != "" {
return fmt.Sprintf("%v (name=%q): %v", e.Type, e.Name, ErrBindingNotFound)
}
return fmt.Sprintf("%v: %v", e.Type, ErrBindingNotFound)
}
type BindError struct {
From reflect.Type
To reflect.Type
Why string
}
func (e BindError) Error() string {
return fmt.Sprintf("bind %v -> %v: %s", e.From, e.To, e.Why)
}