mirror of
https://github.com/grafana/grafana.git
synced 2025-08-02 23:53:10 +08:00
Grafana: Replace magic number with a constant variable in response status (#80132)
* Chore: Replace response status with const var * Apply suggestions from code review Co-authored-by: Sofia Papagiannaki <1632407+papagian@users.noreply.github.com> * Add net/http import --------- Co-authored-by: Sofia Papagiannaki <1632407+papagian@users.noreply.github.com>
This commit is contained in:
@ -18,7 +18,7 @@ import (
|
||||
func (hs *HTTPServer) RenderToPng(c *contextmodel.ReqContext) {
|
||||
queryReader, err := util.NewURLQueryReader(c.Req.URL)
|
||||
if err != nil {
|
||||
c.Handle(hs.Cfg, 400, "Render parameters error", err)
|
||||
c.Handle(hs.Cfg, http.StatusBadRequest, "Render parameters error", err)
|
||||
return
|
||||
}
|
||||
|
||||
@ -36,7 +36,7 @@ func (hs *HTTPServer) RenderToPng(c *contextmodel.ReqContext) {
|
||||
|
||||
timeout, err := strconv.Atoi(queryReader.Get("timeout", "60"))
|
||||
if err != nil {
|
||||
c.Handle(hs.Cfg, 400, "Render parameters error", fmt.Errorf("cannot parse timeout as int: %s", err))
|
||||
c.Handle(hs.Cfg, http.StatusBadRequest, "Render parameters error", fmt.Errorf("cannot parse timeout as int: %s", err))
|
||||
return
|
||||
}
|
||||
|
||||
@ -79,11 +79,11 @@ func (hs *HTTPServer) RenderToPng(c *contextmodel.ReqContext) {
|
||||
}, nil)
|
||||
if err != nil {
|
||||
if errors.Is(err, rendering.ErrTimeout) {
|
||||
c.Handle(hs.Cfg, 500, err.Error(), err)
|
||||
c.Handle(hs.Cfg, http.StatusInternalServerError, err.Error(), err)
|
||||
return
|
||||
}
|
||||
|
||||
c.Handle(hs.Cfg, 500, "Rendering failed.", err)
|
||||
c.Handle(hs.Cfg, http.StatusInternalServerError, "Rendering failed.", err)
|
||||
return
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user