优化错误处理相关代码

This commit is contained in:
GoEdgeLab
2023-08-11 16:13:33 +08:00
parent 310bc107ad
commit 16557ba6d7
19 changed files with 81 additions and 68 deletions

View File

@@ -7,6 +7,7 @@ import (
"crypto/tls"
"encoding/json"
"errors"
"fmt"
teaconst "github.com/TeaOSLab/EdgeAPI/internal/const"
"github.com/TeaOSLab/EdgeAPI/internal/dnsclients/dnstypes"
"github.com/TeaOSLab/EdgeAPI/internal/dnsclients/edgeapi"
@@ -452,7 +453,7 @@ func (this *EdgeDNSAPIProvider) doAPI(path string, params map[string]any, respPt
err = json.Unmarshal(data, respPtr)
if err != nil {
return errors.New("decode response failed: " + err.Error() + ", JSON: " + string(data))
return fmt.Errorf("decode response failed: %w, JSON: %s", err, string(data))
}
if !respPtr.IsValid() {