forked from snwfdhmp/errlog
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfailingLineFar.go
60 lines (45 loc) · 916 Bytes
/
failingLineFar.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
package main
import (
"errors"
"fmt"
"github.com/gregwebs/errlog"
)
var (
debug = errlog.NewLogger(&errlog.Config{
PrintFunc: func(format string, args ...any) { fmt.Printf(format, args...) },
LinesBefore: 6,
LinesAfter: 3,
PrintError: true,
PrintSource: true,
PrintStack: true,
ExitOnDebugSuccess: true,
})
)
func main() {
fmt.Println("Start of the program")
wrapingFunc()
fmt.Println("End of the program")
}
func wrapingFunc() {
someBigFunction()
}
func someBigFunction() {
someDumbFunction()
someSmallFunction()
err := someNastyFunction()
someDumbFunction()
if debug.Debug(err) {
return
}
someSmallFunction()
someDumbFunction()
}
func someSmallFunction() {
fmt.Println("I do things !")
}
func someNastyFunction() error {
return errors.New("I'm failing for no reason")
}
func someDumbFunction() bool {
return false
}