Always return something valid

This commit is contained in:
obscuren 2014-08-21 15:12:13 +02:00
parent c44f4f32fe
commit b368549fd5

View File

@ -276,6 +276,11 @@ func (self *JSFilter) MessagesToJson(messages ethstate.Messages) string {
msgs = append(msgs, NewJSMessage(m)) msgs = append(msgs, NewJSMessage(m))
} }
// Return an empty array instead of "null"
if len(msgs) == 0 {
return "[]"
}
b, err := json.Marshal(msgs) b, err := json.Marshal(msgs)
if err != nil { if err != nil {
return "{\"error\":" + err.Error() + "}" return "{\"error\":" + err.Error() + "}"