-
Notifications
You must be signed in to change notification settings - Fork 0
/
error.go
90 lines (70 loc) · 1.63 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
81
82
83
84
85
86
87
88
89
90
/*
* Author: fasion
* Created time: 2022-11-02 21:47:37
* Last Modified by: fasion
* Last Modified time: 2023-11-23 14:55:05
*/
package baseutils
import (
"fmt"
"github.com/fasionchan/goutils/stl"
)
type GenericNotFoundError struct {
t string
name string
}
func NewGenericNotFoundError(t, name string) GenericNotFoundError {
return GenericNotFoundError{
t: t,
name: name,
}
}
func (e GenericNotFoundError) Name() string {
return e.name
}
func (e GenericNotFoundError) Type() string {
return e.t
}
func (e GenericNotFoundError) Error() string {
return fmt.Sprintf("%s not found: %s", e.Type(), e.Name())
}
type EnvironmentVariableNotFoundError struct {
name string
}
func NewEnvironmentVariableNotFoundError(name string) EnvironmentVariableNotFoundError {
return EnvironmentVariableNotFoundError{
name: name,
}
}
func (e EnvironmentVariableNotFoundError) Name() string {
return e.name
}
func (e EnvironmentVariableNotFoundError) Error() string {
return fmt.Sprintf("environment variable not found: %s", e.name)
}
type CookieNotFoundError struct {
name string
}
func NewCookieNotFoundError(name string) CookieNotFoundError {
return CookieNotFoundError{
name: name,
}
}
func (e CookieNotFoundError) Name() string {
return e.name
}
func (e CookieNotFoundError) Error() string {
return fmt.Sprintf("cookie not found: %s", e.name)
}
type NotImplementedError struct {
hint string
}
func NewNotImplementedError(hint string) NotImplementedError {
return NotImplementedError{
hint: hint,
}
}
func (e NotImplementedError) Error() string {
return fmt.Sprintf("not implemented: %s", e.hint)
}
type Errors = stl.Errors