forked from TeoDev1611/darth-db
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patherrors.go
51 lines (44 loc) · 1.09 KB
/
errors.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
package errors
import (
"errors"
"os"
log "github.com/sirupsen/logrus"
)
/* Set the log options :D */
func init() {
log.SetFormatter(&log.JSONFormatter{PrettyPrint: true})
log.SetOutput(os.Stdout)
log.SetLevel(log.ErrorLevel)
}
/* Generate a Error util */
func NewError(msg string, hight bool) {
/* Check if the error is hight priority */
if hight {
err := errors.New(msg)
/* Write a log message for hight priority */
if err != nil {
log.WithFields(log.Fields{
"error": err,
"msg": "Error Hight level detected",
}).Fatal("FIX THIS ERROR NOW!")
}
/* If not is priority make a simple log :D */
} else {
err := errors.New(msg)
if err != nil {
log.WithFields(log.Fields{
"error": err,
"msg": "Error not hight priority",
}).Error("Fix the error but not more fast or yes ?)")
}
}
}
/* Check errors util function */
func CheckErrors(err error) {
if err != nil {
log.WithFields(log.Fields{
"error": err,
"msg": "Error detected read the error field for more information",
}).Error("New error detected :c if this is a bug report in the repo")
}
}