etcdserver/stats: log any marshaling error

release-2.0
Jonathan Boulle 2014-10-16 19:51:38 -07:00
parent 233e940410
commit 82023c591d
1 changed files with 6 additions and 1 deletions

View File

@ -2,6 +2,7 @@ package stats
import (
"encoding/json"
"log"
"math"
"sync"
"time"
@ -26,7 +27,11 @@ func NewLeaderStats(id string) *LeaderStats {
}
func (ls *LeaderStats) JSON() []byte {
b, _ := json.Marshal(ls)
b, err := json.Marshal(ls)
// TODO(jonboulle): appropriate error handling?
if err != nil {
log.Printf("error marshalling leader stats: %v", err)
}
return b
}