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")
|
pluginID := c.Params("pluginId")
|
||||||
plugin := hs.PluginManager.GetPlugin(pluginID)
|
plugin := hs.PluginManager.GetPlugin(pluginID)
|
||||||
if plugin == nil {
|
if plugin == nil {
|
||||||
c.Handle(hs.Cfg, 404, "Plugin not found", nil)
|
c.JsonApiErr(404, "Plugin not found", nil)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -274,10 +274,10 @@ func (hs *HTTPServer) GetPluginAssets(c *models.ReqContext) {
|
|||||||
f, err := os.Open(pluginFilePath)
|
f, err := os.Open(pluginFilePath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if os.IsNotExist(err) {
|
if os.IsNotExist(err) {
|
||||||
c.Handle(hs.Cfg, 404, "Plugin file not found", err)
|
c.JsonApiErr(404, "Plugin file not found", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
c.Handle(hs.Cfg, 500, "Could not open plugin file", err)
|
c.JsonApiErr(500, "Could not open plugin file", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
defer func() {
|
defer func() {
|
||||||
@ -288,12 +288,12 @@ func (hs *HTTPServer) GetPluginAssets(c *models.ReqContext) {
|
|||||||
|
|
||||||
fi, err := f.Stat()
|
fi, err := f.Stat()
|
||||||
if err != nil {
|
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
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if shouldExclude(fi) {
|
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))
|
fmt.Errorf("access is forbidden to executable plugin file %s", pluginFilePath))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user