Browse Source

etcdserver/stats: log any marshaling error

Jonathan Boulle 11 years ago
parent
commit
82023c591d
1 changed files with 6 additions and 1 deletions
  1. 6 1
      etcdserver/stats/leader.go

+ 6 - 1
etcdserver/stats/leader.go

@@ -2,6 +2,7 @@ package stats
 
 
 import (
 import (
 	"encoding/json"
 	"encoding/json"
+	"log"
 	"math"
 	"math"
 	"sync"
 	"sync"
 	"time"
 	"time"
@@ -26,7 +27,11 @@ func NewLeaderStats(id string) *LeaderStats {
 }
 }
 
 
 func (ls *LeaderStats) JSON() []byte {
 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
 	return b
 }
 }