buildFileValidationError builds an error message from invalid and inaccessible file paths
(invalidPaths, inaccessiblePaths []string)
| 379 | |
| 380 | // buildFileValidationError builds an error message from invalid and inaccessible file paths |
| 381 | func buildFileValidationError(invalidPaths, inaccessiblePaths []string) error { |
| 382 | var errors []string |
| 383 | if len(invalidPaths) > 0 { |
| 384 | errors = append(errors, fmt.Sprintf("file(s) not found: %s", strings.Join(invalidPaths, ", "))) |
| 385 | } |
| 386 | if len(inaccessiblePaths) > 0 { |
| 387 | errors = append(errors, fmt.Sprintf("file(s) not accessible: %s", strings.Join(inaccessiblePaths, ", "))) |
| 388 | } |
| 389 | |
| 390 | if len(errors) > 0 { |
| 391 | return fmt.Errorf("%s", strings.Join(errors, "; ")) |
| 392 | } |
| 393 | return nil |
| 394 | } |
| 395 | |
| 396 | // validateFilePaths validates multiple file paths with a custom separator |
| 397 | func validateFilePaths(files string, separator string) error { |