forked from tmrts/boilr
-
Notifications
You must be signed in to change notification settings - Fork 1
/
exit.go
47 lines (34 loc) · 893 Bytes
/
exit.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
package exit
import (
"fmt"
"os"
"github.com/6uhrmittag/boilr/pkg/util/tlog"
)
const (
// CodeOK indicates successful execution.
CodeOK = 0
// CodeError indicates erroneous execution.
CodeError = 1
// CodeFatal indicates erroneous use by user.
CodeFatal = 2
)
// Fatal terminates execution using fatal exit code.
func Fatal(err error) {
tlog.Fatal(fmt.Sprint(err))
os.Exit(CodeFatal)
}
// Error terminates execution using unsuccessful execution exit code.
func Error(err error) {
tlog.Error(err.Error())
os.Exit(CodeError)
}
// GoodEnough terminates execution successfully, but indicates that something is missing.
func GoodEnough(fmtStr string, s ...interface{}) {
tlog.Info(fmt.Sprintf(fmtStr, s...))
os.Exit(CodeOK)
}
// OK terminates execution successfully.
func OK(fmtStr string, s ...interface{}) {
tlog.Success(fmt.Sprintf(fmtStr, s...))
os.Exit(CodeOK)
}