Register notification hooks first in init to allow sending .init() failure notifications

This commit is contained in:
Lennard Schwarz
2025-12-21 13:40:19 +01:00
parent 16677e631e
commit 3e419229d7
3 changed files with 85 additions and 65 deletions

View File

@@ -63,8 +63,17 @@ func runScript(c *Config) (err error) {
}
if initErr := s.init(); initErr != nil {
err = errwrap.Wrap(initErr, "error instantiating script")
return
if hookErr := s.runHooks(initErr); hookErr != nil {
return errwrap.Wrap(
nil,
fmt.Sprintf(
"error %v instantiating script followed by %v calling the registered hooks",
initErr,
hookErr,
),
)
}
return errwrap.Wrap(initErr, "error instantiating script")
}
return func() (err error) {