fix(alerting): fix bug with unhandled error

closes #6239
This commit is contained in:
bergquist
2016-10-11 17:37:07 +02:00
parent 0d4b00df95
commit ccee1b3f96
3 changed files with 29 additions and 9 deletions
+7 -2
View File
@@ -80,6 +80,11 @@ func (e *DashAlertExtractor) GetAlerts() ([]*m.Alert, error) {
continue
}
frequency, err := getTimeDurationStringToSeconds(jsonAlert.Get("frequency").MustString())
if err != nil {
return nil, ValidationError{Reason: "Could not parse frequency"}
}
alert := &m.Alert{
DashboardId: e.Dash.Id,
OrgId: e.OrgId,
@@ -88,7 +93,7 @@ func (e *DashAlertExtractor) GetAlerts() ([]*m.Alert, error) {
Name: jsonAlert.Get("name").MustString(),
Handler: jsonAlert.Get("handler").MustInt64(),
Message: jsonAlert.Get("message").MustString(),
Frequency: getTimeDurationStringToSeconds(jsonAlert.Get("frequency").MustString()),
Frequency: frequency,
}
for _, condition := range jsonAlert.Get("conditions").MustArray() {
@@ -121,7 +126,7 @@ func (e *DashAlertExtractor) GetAlerts() ([]*m.Alert, error) {
alert.Settings = jsonAlert
// validate
_, err := NewRuleFromDBAlert(alert)
_, err = NewRuleFromDBAlert(alert)
if err == nil && alert.ValidToSave() {
alerts = append(alerts, alert)
} else {