mirror of
https://github.com/prometheus/prometheus.git
synced 2025-01-12 06:17:27 -08:00
Fixed error handling
Signed-off-by: Levi Harrison <git@leviharrison.dev>
This commit is contained in:
parent
dc586b2495
commit
34e1b47968
|
@ -911,20 +911,17 @@ func importRules(url *url.URL, start, end, outputDir string, evalInterval time.D
|
|||
} else {
|
||||
etime, err = parseTime(end)
|
||||
if err != nil {
|
||||
fmt.Fprintln(os.Stderr, "error parsing end time:", err)
|
||||
return err
|
||||
return fmt.Errorf("error parsing end time: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
stime, err = parseTime(start)
|
||||
if err != nil {
|
||||
fmt.Fprintln(os.Stderr, "error parsing start time:", err)
|
||||
return err
|
||||
return fmt.Errorf("error parsing start time: %v", err)
|
||||
}
|
||||
|
||||
if !stime.Before(etime) {
|
||||
fmt.Fprintln(os.Stderr, "start time is not before end time")
|
||||
return nil
|
||||
return errors.New("start time is not before end time")
|
||||
}
|
||||
|
||||
cfg := ruleImporterConfig{
|
||||
|
@ -937,25 +934,24 @@ func importRules(url *url.URL, start, end, outputDir string, evalInterval time.D
|
|||
Address: url.String(),
|
||||
})
|
||||
if err != nil {
|
||||
fmt.Fprintln(os.Stderr, "new api client error", err)
|
||||
return err
|
||||
return fmt.Errorf("new api client error: %v", err)
|
||||
}
|
||||
|
||||
ruleImporter := newRuleImporter(log.NewLogfmtLogger(log.NewSyncWriter(os.Stderr)), cfg, v1.NewAPI(client))
|
||||
errs := ruleImporter.loadGroups(ctx, files)
|
||||
for _, err := range errs {
|
||||
if err != nil {
|
||||
fmt.Fprintln(os.Stderr, "rule importer parse error", err)
|
||||
return err
|
||||
return fmt.Errorf("rule importer parse error: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
errs = ruleImporter.importAll(ctx)
|
||||
for _, err := range errs {
|
||||
if err != nil {
|
||||
fmt.Fprintln(os.Stderr, "rule importer error", err)
|
||||
}
|
||||
fmt.Fprintln(os.Stderr, "rule importer error:", err)
|
||||
}
|
||||
if len(errs) > 0 {
|
||||
return errors.New("error importing rules")
|
||||
}
|
||||
|
||||
return err
|
||||
return nil
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue