|
|
|
@ -50,6 +50,7 @@ const (
|
|
|
|
|
errorCanceled = "canceled" |
|
|
|
|
errorExec = "execution" |
|
|
|
|
errorBadData = "bad_data" |
|
|
|
|
errorInternal = "internal" |
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
var corsHeaders = map[string]string{ |
|
|
|
@ -194,6 +195,8 @@ func (api *API) query(r *http.Request) (interface{}, *apiError) {
|
|
|
|
|
return nil, &apiError{errorCanceled, res.Err} |
|
|
|
|
case promql.ErrQueryTimeout: |
|
|
|
|
return nil, &apiError{errorTimeout, res.Err} |
|
|
|
|
case promql.ErrStorage: |
|
|
|
|
return nil, &apiError{errorInternal, res.Err} |
|
|
|
|
} |
|
|
|
|
return nil, &apiError{errorExec, res.Err} |
|
|
|
|
} |
|
|
|
@ -459,6 +462,8 @@ func respondError(w http.ResponseWriter, apiErr *apiError, data interface{}) {
|
|
|
|
|
code = 422 |
|
|
|
|
case errorCanceled, errorTimeout: |
|
|
|
|
code = http.StatusServiceUnavailable |
|
|
|
|
case errorInternal: |
|
|
|
|
code = http.StatusInternalServerError |
|
|
|
|
default: |
|
|
|
|
code = http.StatusInternalServerError |
|
|
|
|
} |
|
|
|
|