♻️ 将退出码移到 logging 项目中

This commit is contained in:
Liang Ding 2023-03-18 18:10:06 +08:00
parent e99b7fd588
commit 2601605953
No known key found for this signature in database
GPG key ID: 136F30F901A2231D
13 changed files with 29 additions and 39 deletions

View file

@ -325,7 +325,7 @@ func InitBlockTree(force bool) {
entries, err := os.ReadDir(util.BlockTreePath)
if nil != err {
logging.LogErrorf("read block tree dir failed: %s", err)
os.Exit(util.ExitCodeBlockTreeErr)
os.Exit(logging.ExitCodeBlockTreeErr)
return
}
@ -342,7 +342,7 @@ func InitBlockTree(force bool) {
fh, err = os.OpenFile(p, os.O_RDWR, 0644)
if nil != err {
logging.LogErrorf("open block tree file failed: %s", err)
os.Exit(util.ExitCodeBlockTreeErr)
os.Exit(logging.ExitCodeBlockTreeErr)
return
}
@ -351,7 +351,7 @@ func InitBlockTree(force bool) {
fh.Close()
if nil != err {
logging.LogErrorf("read block tree failed: %s", err)
os.Exit(util.ExitCodeBlockTreeErr)
os.Exit(logging.ExitCodeBlockTreeErr)
return
}
@ -361,7 +361,7 @@ func InitBlockTree(force bool) {
if err = os.RemoveAll(util.BlockTreePath); nil != err {
logging.LogErrorf("removed corrupted block tree failed: %s", err)
}
os.Exit(util.ExitCodeBlockTreeErr)
os.Exit(logging.ExitCodeBlockTreeErr)
return
}
@ -410,7 +410,7 @@ func SaveBlockTree(force bool) {
data, err := msgpack.Marshal(slice.data)
if nil != err {
logging.LogErrorf("marshal block tree failed: %s", err)
os.Exit(util.ExitCodeBlockTreeErr)
os.Exit(logging.ExitCodeBlockTreeErr)
return false
}
slice.m.Unlock()
@ -418,7 +418,7 @@ func SaveBlockTree(force bool) {
p := filepath.Join(util.BlockTreePath, key.(string)) + ".msgpack"
if err = gulu.File.WriteFileSafer(p, data, 0644); nil != err {
logging.LogErrorf("write block tree failed: %s", err)
os.Exit(util.ExitCodeBlockTreeErr)
os.Exit(logging.ExitCodeBlockTreeErr)
return false
}