Error from run_script is not consistently passed to deferred functions

This commit is contained in:
Frederik Ring
2025-12-22 16:16:32 +01:00
parent 3e419229d7
commit d52a2a318f

View File

@@ -64,7 +64,7 @@ func runScript(c *Config) (err error) {
if initErr := s.init(); initErr != nil { if initErr := s.init(); initErr != nil {
if hookErr := s.runHooks(initErr); hookErr != nil { if hookErr := s.runHooks(initErr); hookErr != nil {
return errwrap.Wrap( err = errwrap.Wrap(
nil, nil,
fmt.Sprintf( fmt.Sprintf(
"error %v instantiating script followed by %v calling the registered hooks", "error %v instantiating script followed by %v calling the registered hooks",
@@ -72,11 +72,13 @@ func runScript(c *Config) (err error) {
hookErr, hookErr,
), ),
) )
return
} }
return errwrap.Wrap(initErr, "error instantiating script") err = errwrap.Wrap(initErr, "error instantiating script")
return
} }
return func() (err error) { err = func() (err error) {
scriptErr := func() error { scriptErr := func() error {
if err := s.withLabeledCommands(lifecyclePhaseArchive, func() (err error) { if err := s.withLabeledCommands(lifecyclePhaseArchive, func() (err error) {
restartContainersAndServices, err := s.stopContainersAndServices() restartContainersAndServices, err := s.stopContainersAndServices()
@@ -130,4 +132,6 @@ func runScript(c *Config) (err error) {
} }
return nil return nil
}() }()
return
} }