优化错误处理相关代码

This commit is contained in:
刘祥超
2023-08-11 14:51:23 +08:00
parent 2eee314ec8
commit 70d8507c4b
10 changed files with 16 additions and 17 deletions
+2 -2
View File
@@ -1,7 +1,7 @@
package nodes
import (
"errors"
"fmt"
"github.com/TeaOSLab/EdgeCommon/pkg/nodeconfigs"
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs"
teaconst "github.com/TeaOSLab/EdgeNode/internal/const"
@@ -141,7 +141,7 @@ func (this *ListenerManager) Start(nodeConfig *nodeconfigs.NodeConfig) error {
var port = addr[portIndex+1:]
var processName = this.findProcessNameWithPort(group.IsUDP(), port)
if len(processName) > 0 {
err = errors.New(err.Error() + " (the process using port: '" + processName + "')")
err = fmt.Errorf("%w (the process using port: '%s')", err, processName)
}
}
}
+1 -1
View File
@@ -324,7 +324,7 @@ func (this *Node) syncConfig(taskVersion int64) error {
if os.IsNotExist(clusterErr) {
return errors.New("can not find config file 'configs/api.yaml'")
}
return errors.New("check cluster config failed: " + clusterErr.Error())
return fmt.Errorf("check cluster config failed: %w", clusterErr)
}
} else {
return err