sync: Use errors instead of string to report

This commit is contained in:
nemunaire 2022-07-02 00:01:05 +02:00
commit b0129e5239
9 changed files with 186 additions and 178 deletions

View file

@ -87,12 +87,12 @@ func parseExerciceParams(i Importer, exPath string) (p ExerciceParams, md toml.M
}
// getExerciceParams returns normalized
func getExerciceParams(i Importer, exercice *fic.Exercice) (params ExerciceParams, errs []string) {
func getExerciceParams(i Importer, exercice *fic.Exercice) (params ExerciceParams, errs []error) {
var err error
if params, _, err = parseExerciceParams(i, exercice.Path); err != nil {
errs = append(errs, fmt.Sprintf("%q: challenge.txt: %s", path.Base(exercice.Path), err))
errs = append(errs, fmt.Errorf("%q: challenge.txt: %w", path.Base(exercice.Path), err))
} else if len(params.Flags) == 0 && len(params.FlagsUCQ) == 0 && len(params.FlagsMCQ) == 0 {
errs = append(errs, fmt.Sprintf("%q: has no flag", path.Base(exercice.Path)))
errs = append(errs, fmt.Errorf("%q: has no flag", path.Base(exercice.Path)))
} else {
// Treat legacy UCQ flags as ExerciceFlag
for _, flag := range params.FlagsUCQ {