track error (#1815)

* track error

* remove useless code

Co-authored-by: huanghuan.27@bytedance.com <huanghuan.27@bytedance.com>
Co-authored-by: Asim Aslam <asim@aslam.me>
This commit is contained in:
Huan Huang 2020-07-12 14:17:56 +08:00 committed by GitHub
parent 630ceb5dad
commit 8e30ede8c7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -84,14 +84,22 @@ func encode(txt *mdnsTxt) ([]string, error) {
defer buf.Reset() defer buf.Reset()
w := zlib.NewWriter(&buf) w := zlib.NewWriter(&buf)
defer func() {
if closeErr := w.Close(); closeErr != nil {
if logger.V(logger.ErrorLevel, logger.DefaultLogger) {
logger.Errorf("[mdns] registry close encoding writer err: %v", closeErr)
}
}
}()
if _, err := w.Write(b); err != nil { if _, err := w.Write(b); err != nil {
w.Close()
return nil, err return nil, err
} }
w.Close()
if err = w.Close(); err != nil {
return nil, err
}
encoded := hex.EncodeToString(buf.Bytes()) encoded := hex.EncodeToString(buf.Bytes())
// individual txt limit // individual txt limit
if len(encoded) <= 255 { if len(encoded) <= 255 {
return []string{encoded}, nil return []string{encoded}, nil