优化错误处理相关代码

This commit is contained in:
刘祥超
2023-08-11 16:13:33 +08:00
parent 034ababead
commit d1ba141c65
19 changed files with 81 additions and 68 deletions

View File

@@ -1,9 +1,8 @@
package dnsclients
import (
"errors"
"fmt"
"github.com/TeaOSLab/EdgeAPI/internal/dnsclients/dnstypes"
"github.com/iwind/TeaGo/types"
)
type BaseProvider struct{}
@@ -24,5 +23,5 @@ func (this *BaseProvider) WrapError(err error, domain string, record *dnstypes.R
} else {
fullname = record.Name + "." + domain
}
return errors.New("record operation failed: '" + fullname + " " + record.Type + " " + record.Value + " " + types.String(record.TTL) + "': " + err.Error())
return fmt.Errorf("record operation failed: '%s %s %s %d': %w", fullname, record.Type, record.Value, record.TTL, err)
}