refactor dashboard alert extractor

This commit is contained in:
Marcus Efraimsson
2018-11-05 14:25:19 +01:00
parent c5ce8536d4
commit 9e0da02b6a
7 changed files with 39 additions and 15 deletions
+4
View File
@@ -134,12 +134,16 @@ func AlertTest(c *m.ReqContext, dto dtos.AlertTestCommand) Response {
OrgId: c.OrgId,
Dashboard: dto.Dashboard,
PanelId: dto.PanelId,
User: c.SignedInUser,
}
if err := bus.Dispatch(&backendCmd); err != nil {
if validationErr, ok := err.(alerting.ValidationError); ok {
return Error(422, validationErr.Error(), nil)
}
if err == m.ErrDataSourceAccessDenied {
return Error(403, "Access denied to datasource", err)
}
return Error(500, "Failed to test rule", err)
}