-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
76 lines (64 loc) · 1.43 KB
/
main.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
package main
import (
"log"
"github.com/aperezg/sample-errors/behaviour"
"github.com/aperezg/sample-errors/behaviour113"
"github.com/aperezg/sample-errors/sentinels"
)
func main() {
// sentinels
fetchSomethingWithSentinels()
fetchSomethingWithSentinelsWithWrap()
// behaviour
fetchSomethingBehaviour()
fetchSomethingWithWrapBehaviour()
// 113
fetchSomething113()
fetchSomethingWithWrap113()
}
func fetchSomethingWithSentinels() {
err := sentinels.SearchSomething()
if err == sentinels.ErrEmptyData {
log.Println(err)
} else if err != nil {
log.Fatal("fatal sentinel")
}
}
func fetchSomethingWithSentinelsWithWrap() {
err := sentinels.SearchWithWraping()
if err != nil {
log.Println(err)
}
}
func fetchSomethingBehaviour() {
err := behaviour.SearchSomething()
if behaviour.IsNotFound(err) {
log.Println(err)
} else if err != nil {
log.Fatal("fatal behaviour")
}
}
func fetchSomethingWithWrapBehaviour() {
err := behaviour.SearchWithWraping()
if behaviour.IsNotFound(err) {
log.Println(err)
} else if err != nil {
log.Fatal("fatal wrap behaviour")
}
}
func fetchSomething113() {
err := behaviour113.SearchSomething()
if behaviour113.IsNotFound(err) {
log.Println(err)
} else if err != nil {
log.Fatal("fatal 113")
}
}
func fetchSomethingWithWrap113() {
err := behaviour113.SearchWithWraping()
if behaviour113.IsNotFound(err) {
log.Println(err)
} else if err != nil {
log.Fatal("fatal wrap 113")
}
}