Skip to content

Commit

Permalink
Tariff: better rate matching error (#17255)
Browse files Browse the repository at this point in the history
  • Loading branch information
naltatis authored Nov 14, 2024
1 parent 52ca2c8 commit 1a8b412
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions api/rates.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package api

import (
"errors"
"fmt"
"slices"
"time"
)
Expand Down Expand Up @@ -36,5 +36,9 @@ func (r Rates) Current(now time.Time) (Rate, error) {
}
}

return Rate{}, errors.New("no matching rate")
if len(r) == 0 {
return Rate{}, fmt.Errorf("no matching rate for: %s", now.Local().Format(time.RFC3339))
}
return Rate{}, fmt.Errorf("no matching rate for: %s, %d rates (%s to %s)",
now.Local().Format(time.RFC3339), len(r), r[0].Start.Local().Format(time.RFC3339), r[len(r)-1].End.Local().Format(time.RFC3339))
}

0 comments on commit 1a8b412

Please sign in to comment.