Show hook-timout flag in error message
Show the flag when hook times out so that users can use it to increase
timeout time.
Change-Id: Ibacaa2e323c4f0ecf285a373ca39a9420bb7d5c3
diff --git a/project/project.go b/project/project.go
index 8b4e05b..d1cfad9 100644
--- a/project/project.go
+++ b/project/project.go
@@ -2400,6 +2400,7 @@
}
err = nil
+ timeout := false
for range hooks {
out := <-ch
defer func() {
@@ -2411,12 +2412,13 @@
}
}()
if out.err == context.DeadlineExceeded {
+ timeout = true
out.outFile.Sync()
out.outFile.Seek(0, 0)
var buf bytes.Buffer
io.Copy(&buf, out.outFile)
jirix.Logger.Errorf("Timeout while executing hook\n%s\n\n", buf.String())
- err = fmt.Errorf("Hooks execution failed")
+ err = fmt.Errorf("Hooks execution failed.")
continue
}
var outBuf bytes.Buffer
@@ -2433,13 +2435,15 @@
io.Copy(&buf, out.errFile)
}
jirix.Logger.Errorf("%s\n%s\n%s\n", out.err, buf.String(), outBuf.String())
- err = fmt.Errorf("Hooks execution failed")
+ err = fmt.Errorf("Hooks execution failed.")
} else {
if outBuf.String() != "" {
jirix.Logger.Debugf("%s\n", outBuf.String())
}
}
-
+ }
+ if timeout {
+ err = fmt.Errorf("%s Use %s flag to set timeout.", err, jirix.Color.Yellow("-hook-timeout"))
}
return err
}