mirror of
https://github.com/grafana/grafana.git
synced 2024-11-25 18:30:41 -06:00
03114e7602
* Return better error for invalid time range * drop comment
22 lines
1.2 KiB
Go
22 lines
1.2 KiB
Go
package models
|
|
|
|
import (
|
|
"github.com/grafana/grafana/pkg/util/errutil"
|
|
)
|
|
|
|
var (
|
|
errAlertRuleConflictMsg = "conflicting alert rule found [rule_uid: '{{ .Public.RuleUID }}', title: '{{ .Public.Title }}', namespace_uid: '{{ .Public.NamespaceUID }}']: {{ .Public.Error }}"
|
|
ErrAlertRuleConflictBase = errutil.Conflict("alerting.alert-rule.conflict").
|
|
MustTemplate(errAlertRuleConflictMsg, errutil.WithPublic(errAlertRuleConflictMsg))
|
|
ErrAlertRuleGroupNotFound = errutil.NotFound("alerting.alert-rule.notFound")
|
|
ErrInvalidRelativeTimeRangeBase = errutil.BadRequest("alerting.alert-rule.invalidRelativeTime").MustTemplate("Invalid alert rule query {{ .Public.RefID }}: invalid relative time range [From: {{ .Public.From }}, To: {{ .Public.To }}]")
|
|
)
|
|
|
|
func ErrAlertRuleConflict(rule AlertRule, underlying error) error {
|
|
return ErrAlertRuleConflictBase.Build(errutil.TemplateData{Public: map[string]any{"RuleUID": rule.UID, "Title": rule.Title, "NamespaceUID": rule.NamespaceUID, "Error": underlying.Error()}, Error: underlying})
|
|
}
|
|
|
|
func ErrInvalidRelativeTimeRange(refID string, rtr RelativeTimeRange) error {
|
|
return ErrInvalidRelativeTimeRangeBase.Build(errutil.TemplateData{Public: map[string]any{"RefID": refID, "From": rtr.From, "To": rtr.To}})
|
|
}
|