Skip to content

Commit 45786ba

Browse files
aman4433Copilot
andauthored
Update pkg/machinery/scaffold.go
Co-authored-by: Copilot <[email protected]>
1 parent acce86a commit 45786ba

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

pkg/machinery/scaffold.go

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -238,12 +238,20 @@ func (s Scaffold) updateFileModel(i Inserter, models map[string]*File) error {
238238
m, err := s.loadPreviousModel(i, models)
239239
if err != nil {
240240
if os.IsNotExist(err) {
241-
if withOptionalBehavior, ok := i.(HasIfNotExistsAction); ok &&
242-
withOptionalBehavior.GetIfNotExistsAction() == IgnoreFile {
243-
log.Warnf("Skipping missing file: %s", i.GetPath())
244-
log.Warn("The code fragments will not be inserted.")
245-
return nil
241+
if withOptionalBehavior, ok := i.(HasIfNotExistsAction); ok {
242+
switch withOptionalBehavior.GetIfNotExistsAction() {
243+
case IgnoreFile:
244+
log.Warnf("Skipping missing file: %s", i.GetPath())
245+
log.Warn("The code fragments will not be inserted.")
246+
return nil
247+
case ErrorIfNotExist:
248+
return err
249+
default:
250+
return err
251+
}
246252
}
253+
// If HasIfNotExistsAction is not implemented, return the original error
254+
return err
247255
}
248256
return fmt.Errorf("failed to load previous model for %s: %w", i.GetPath(), err)
249257
}

0 commit comments

Comments
 (0)