ds-querier: handle execute errors better (#105496)
* ds-querier: handle execute errors better * fix: change how GetResponseCode works to return 418 if rsp is nil 418 is a bit of an easter egg which in this case works since we don't have an rsp but we do know something went wrong, so a 200 won't work. Also changed this to return the code in the frame, not sure why we weren't. * tests: fix GetResponseCode tests * log no rsp case * bring back og error log
This commit is contained in:
@@ -31,11 +31,15 @@ type QueryDataResponse struct {
|
||||
// GetResponseCode return the right status code for the response by checking the responses.
|
||||
func GetResponseCode(rsp *backend.QueryDataResponse) int {
|
||||
if rsp == nil {
|
||||
return http.StatusBadRequest
|
||||
return http.StatusTeapot // rsp is nil, so we return a teapot
|
||||
}
|
||||
for _, res := range rsp.Responses {
|
||||
if res.Error != nil && res.Status != 0 {
|
||||
return int(res.Status)
|
||||
}
|
||||
|
||||
if res.Error != nil {
|
||||
return http.StatusBadRequest
|
||||
return http.StatusTeapot // Status is nil but we have an error, so we return a teapot
|
||||
}
|
||||
}
|
||||
return http.StatusOK
|
||||
|
||||
Reference in New Issue
Block a user