优化错误处理相关代码

This commit is contained in:
GoEdgeLab
2023-08-11 14:38:00 +08:00
parent 9396fa5094
commit 85b6692548
17 changed files with 87 additions and 76 deletions

View File

@@ -3,7 +3,7 @@
package nodes
import (
"errors"
"fmt"
"github.com/TeaOSLab/EdgeCommon/pkg/nodeconfigs"
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs/firewallconfigs"
"github.com/TeaOSLab/EdgeNode/internal/conns"
@@ -98,7 +98,7 @@ func (this *ClientConn) Read(b []byte) (n int, err error) {
defer func() {
if err != nil {
this.lastErr = errors.New("read error: " + err.Error())
this.lastErr = fmt.Errorf("read error: %w", err)
} else {
this.lastErr = nil
}
@@ -163,7 +163,7 @@ func (this *ClientConn) Write(b []byte) (n int, err error) {
defer func() {
if err != nil {
this.lastErr = errors.New("write error: " + err.Error())
this.lastErr = fmt.Errorf("write error: %w", err)
} else {
this.lastErr = nil
}