-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy patherror.go
80 lines (62 loc) · 1.73 KB
/
error.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
78
79
80
package hime
import (
"errors"
"fmt"
)
// Errors
var (
ErrAppNotFound = errors.New("hime: app not found")
)
// ErrRouteNotFound is the error for route not found
type ErrRouteNotFound struct {
Route string
}
func (err *ErrRouteNotFound) Error() string {
return fmt.Sprintf("hime: route '%s' not found", err.Route)
}
func newErrRouteNotFound(route string) error {
return &ErrRouteNotFound{route}
}
// ErrTemplateNotFound is the error for template not found
type ErrTemplateNotFound struct {
Name string
}
func (err *ErrTemplateNotFound) Error() string {
return fmt.Sprintf("hime: template '%s' not found", err.Name)
}
func newErrTemplateNotFound(name string) error {
return &ErrTemplateNotFound{name}
}
// ErrTemplateDuplicate is the error for template duplicate
type ErrTemplateDuplicate struct {
Name string
}
func (err *ErrTemplateDuplicate) Error() string {
return fmt.Sprintf("hime: template '%s' already exists", err.Name)
}
func newErrTemplateDuplicate(name string) error {
return &ErrTemplateDuplicate{name}
}
func panicf(format string, a ...any) {
panic(fmt.Sprintf("hime: "+format, a...))
}
// ErrComponentNotFound is the error for component not found
type ErrComponentNotFound struct {
Name string
}
func (err *ErrComponentNotFound) Error() string {
return fmt.Sprintf("hime: component '%s' not found", err.Name)
}
func newErrComponentNotFound(name string) error {
return &ErrComponentNotFound{name}
}
// ErrComponentDuplicate is the error for component duplicate
type ErrComponentDuplicate struct {
Name string
}
func (err *ErrComponentDuplicate) Error() string {
return fmt.Sprintf("hime: component '%s' already exists", err.Name)
}
func newErrComponentDuplicate(name string) error {
return &ErrComponentDuplicate{name}
}