Skip to content

Commit

Permalink
Add downstream to interval parsing (#1088)
Browse files Browse the repository at this point in the history
  • Loading branch information
idastambuk authored Sep 17, 2024
1 parent eddefb0 commit 22ef5f5
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions backend/gtime/gtime.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import (
"strconv"
"strings"
"time"

"github.com/grafana/grafana-plugin-sdk-go/experimental/errorsource"
)

var dateUnitPattern = regexp.MustCompile(`^(\d+)([dwMy])$`)
Expand Down Expand Up @@ -37,7 +39,7 @@ func ParseInterval(inp string) (time.Duration, error) {
return now.AddDate(num, 0, 0).Sub(now), nil
}

return 0, fmt.Errorf("invalid interval %q", inp)
return 0, errorsource.DownstreamError(fmt.Errorf("invalid interval %q", inp), false)
}

// ParseDuration parses a duration with support for all units that Grafana uses.
Expand Down Expand Up @@ -69,7 +71,7 @@ func ParseDuration(inp string) (time.Duration, error) {
return dur * year, nil
}

return 0, fmt.Errorf("invalid duration %q", inp)
return 0, errorsource.DownstreamError(fmt.Errorf("invalid duration %q", inp), false)
}

func parse(inp string) (time.Duration, string, error) {
Expand Down

0 comments on commit 22ef5f5

Please sign in to comment.