Skip to content

Commit 35d93c4

Browse files
committed
loader: include filename in errors
When loading Compose files, if there's an error during YAML parsing or schema validation, wrap the error to explain what part of loading it was and the filename. Signed-off-by: Milas Bowman <[email protected]>
1 parent 270da2d commit 35d93c4

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

loader/loader.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ func Load(configDetails types.ConfigDetails, options ...func(*Options)) (*types.
193193
}
194194
dict, err := parseConfig(file.Content, opts)
195195
if err != nil {
196-
return nil, err
196+
return nil, fmt.Errorf("parsing %s: %w", file.Filename, err)
197197
}
198198
configDict = dict
199199
file.Config = dict
@@ -202,7 +202,7 @@ func Load(configDetails types.ConfigDetails, options ...func(*Options)) (*types.
202202

203203
if !opts.SkipValidation {
204204
if err := schema.Validate(configDict); err != nil {
205-
return nil, err
205+
return nil, fmt.Errorf("validating %s: %w", file.Filename, err)
206206
}
207207
}
208208

0 commit comments

Comments
 (0)