Skip to content

Commit b774256

Browse files
committed
Nicer error messages
Signed-off-by: David Gageot <david.gageot@docker.com>
1 parent 3a12c1f commit b774256

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

pkg/config/config.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,22 +80,22 @@ func ValidatePathInDirectory(path, allowedDir string) (string, error) {
8080
func loadConfig(path string) (*latest.Config, error) {
8181
data, err := os.ReadFile(path)
8282
if err != nil {
83-
return nil, fmt.Errorf("failed to read config file: %w", err)
83+
return nil, fmt.Errorf("reading config file: %w", err)
8484
}
8585

8686
var raw map[string]any
8787
if err := yaml.Unmarshal(data, &raw); err != nil {
88-
return nil, fmt.Errorf("failed to parse config file %s: %w", path, err)
88+
return nil, fmt.Errorf("parsing config file %s\n%s", path, yaml.FormatError(err, true, true))
8989
}
9090

9191
oldConfig, err := parseCurrentVersion(data, raw["version"])
9292
if err != nil {
93-
return nil, fmt.Errorf("failed to parse config file %s: %w", path, err)
93+
return nil, fmt.Errorf("parsing config file %s\n%s", path, yaml.FormatError(err, true, true))
9494
}
9595

9696
config, err := migrateToLatestConfig(oldConfig)
9797
if err != nil {
98-
return nil, fmt.Errorf("failed to migrate config: %w", err)
98+
return nil, fmt.Errorf("migrating config: %w", err)
9999
}
100100

101101
if err := validateConfig(&config); err != nil {

0 commit comments

Comments
 (0)