mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
switch to json resp for errors (#36743)
This commit is contained in:
parent
9b329804e1
commit
e82f8dbef9
@ -261,7 +261,7 @@ func (hs *HTTPServer) GetPluginAssets(c *models.ReqContext) {
|
||||
pluginID := c.Params("pluginId")
|
||||
plugin := hs.PluginManager.GetPlugin(pluginID)
|
||||
if plugin == nil {
|
||||
c.Handle(hs.Cfg, 404, "Plugin not found", nil)
|
||||
c.JsonApiErr(404, "Plugin not found", nil)
|
||||
return
|
||||
}
|
||||
|
||||
@ -274,10 +274,10 @@ func (hs *HTTPServer) GetPluginAssets(c *models.ReqContext) {
|
||||
f, err := os.Open(pluginFilePath)
|
||||
if err != nil {
|
||||
if os.IsNotExist(err) {
|
||||
c.Handle(hs.Cfg, 404, "Plugin file not found", err)
|
||||
c.JsonApiErr(404, "Plugin file not found", err)
|
||||
return
|
||||
}
|
||||
c.Handle(hs.Cfg, 500, "Could not open plugin file", err)
|
||||
c.JsonApiErr(500, "Could not open plugin file", err)
|
||||
return
|
||||
}
|
||||
defer func() {
|
||||
@ -288,12 +288,12 @@ func (hs *HTTPServer) GetPluginAssets(c *models.ReqContext) {
|
||||
|
||||
fi, err := f.Stat()
|
||||
if err != nil {
|
||||
c.Handle(hs.Cfg, 500, "Plugin file exists but could not open", err)
|
||||
c.JsonApiErr(500, "Plugin file exists but could not open", err)
|
||||
return
|
||||
}
|
||||
|
||||
if shouldExclude(fi) {
|
||||
c.Handle(hs.Cfg, 403, "Plugin file access forbidden",
|
||||
c.JsonApiErr(403, "Plugin file access forbidden",
|
||||
fmt.Errorf("access is forbidden to executable plugin file %s", pluginFilePath))
|
||||
return
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user