From 268a69008173d53ed659b40a278c29c454b850ff Mon Sep 17 00:00:00 2001 From: Arran Ubels Date: Wed, 15 Feb 2023 16:26:18 +1100 Subject: [PATCH] So people don't have to check the string they can use the new errors.Is function --- parseany.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/parseany.go b/parseany.go index 73b0585..dd0ea85 100644 --- a/parseany.go +++ b/parseany.go @@ -133,11 +133,12 @@ const ( var ( // ErrAmbiguousMMDD for date formats such as 04/02/2014 the mm/dd vs dd/mm are // ambiguous, so it is an error for strict parse rules. - ErrAmbiguousMMDD = fmt.Errorf("this date has ambiguous mm/dd vs dd/mm type format") + ErrAmbiguousMMDD = fmt.Errorf("this date has ambiguous mm/dd vs dd/mm type format") + ErrCouldntFindFormat = fmt.Errorf("could not find format for") ) func unknownErr(datestr string) error { - return fmt.Errorf("Could not find format for %q", datestr) + return fmt.Errorf("%w %q", ErrCouldntFindFormat, datestr) } // ParseAny parse an unknown date format, detect the layout.