1
0
Fork 0
mirror of https://github.com/Eggbertx/gochan.git synced 2025-09-06 11:46:24 -07:00

Refactor duration error checking to use errors from durationutil pkg

This commit is contained in:
Eggbertx 2023-08-30 11:20:24 -07:00
parent c07d610ee5
commit 13f97233a8
2 changed files with 2 additions and 5 deletions

View file

@ -62,7 +62,7 @@ func (gcfg *GochanConfig) ValidateValues() error {
changed := false
_, err := durationutil.ParseLongerDuration(gcfg.CookieMaxAge)
if err == gcutil.ErrInvalidDurationString {
if errors.Is(err, durationutil.ErrInvalidDurationString) {
return &InvalidValueError{Field: "CookieMaxAge", Value: gcfg.CookieMaxAge, Details: err.Error() + cookieMaxAgeEx}
} else if err != nil {
return err

View file

@ -29,10 +29,7 @@ const (
var (
// ErrNotImplemented should be used for unimplemented functionality when necessary, not for bugs
ErrNotImplemented = errors.New("not implemented")
ErrEmptyDurationString = errors.New("empty duration string")
ErrInvalidDurationString = errors.New("invalid duration string")
durationRegexp = regexp.MustCompile(`^((\d+)\s?ye?a?r?s?)?\s?((\d+)\s?mon?t?h?s?)?\s?((\d+)\s?we?e?k?s?)?\s?((\d+)\s?da?y?s?)?\s?((\d+)\s?ho?u?r?s?)?\s?((\d+)\s?mi?n?u?t?e?s?)?\s?((\d+)\s?s?e?c?o?n?d?s?)?$`)
ErrNotImplemented = errors.New("not implemented")
)
// BcryptSum generates and returns a checksum using the bcrypt hashing function