Return a clearer response if no DB results
This shouldn't happen, but it might, this will allow the underlying
error to be returned to the caller. The body of the response will now
look something like:
{
"results": [],
"error": "some error",
"time": 0.021976516
}
@@ -115,7 +115,7 @@ func (d *DBResults) MarshalJSON() ([]byte, error) {
} else if d.QueryRows != nil {
return encoding.JSONMarshal(d.QueryRows)
}
- return nil, fmt.Errorf("no DB results set")
+ return json.Marshal(make([]interface{}, 0)) // Any empty list.
}
// Response represents a response from the HTTP service.
