Merge lp:~mvo/snappy/snappy-more-errors-15.04 into lp:~snappy-dev/snappy/15.04-deprecated

Proposed by Michael Vogt on 2015-05-26
Status: Merged
Approved by: John Lenton on 2015-05-28
Approved revision: 440
Merged at revision: 445
Proposed branch: lp:~mvo/snappy/snappy-more-errors-15.04
Merge into: lp:~snappy-dev/snappy/15.04-deprecated
Diff against target: 33 lines (+4/-2)
2 files modified
snappy/click.go (+2/-1)
snappy/errors.go (+2/-1)
To merge this branch: bzr merge lp:~mvo/snappy/snappy-more-errors-15.04
Reviewer Review Type Date Requested Status
John Lenton 2015-05-26 Approve on 2015-05-28
Review via email: mp+260112@code.launchpad.net

Commit Message

Improve error reporting for failed hooks.

Description of the Change

Improve error reporting for failed hooks.

To post a comment you must log in.
John Lenton (chipaca) wrote :

Thanks!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'snappy/click.go'
2--- snappy/click.go 2015-05-01 12:32:20 +0000
3+++ snappy/click.go 2015-05-26 09:23:14 +0000
4@@ -99,9 +99,10 @@
5 func execHook(execCmd string) (err error) {
6 // the spec says this is passed to the shell
7 cmd := exec.Command("sh", "-c", execCmd)
8- if err = cmd.Run(); err != nil {
9+ if output, err := cmd.CombinedOutput(); err != nil {
10 if exitCode, err := helpers.ExitCode(err); err == nil {
11 return &ErrHookFailed{cmd: execCmd,
12+ output: string(output),
13 exitCode: exitCode}
14 }
15 return err
16
17=== modified file 'snappy/errors.go'
18--- snappy/errors.go 2015-05-01 12:32:42 +0000
19+++ snappy/errors.go 2015-05-26 09:23:14 +0000
20@@ -178,11 +178,12 @@
21 // ErrHookFailed is returned if a hook command fails
22 type ErrHookFailed struct {
23 cmd string
24+ output string
25 exitCode int
26 }
27
28 func (e *ErrHookFailed) Error() string {
29- return fmt.Sprintf("hook command %v failed with exit status %d", e.cmd, e.exitCode)
30+ return fmt.Sprintf("hook command %v failed with exit status %d (output: '%s')", e.cmd, e.exitCode, e.output)
31 }
32
33 // ErrDataCopyFailed is returned if copying the snap data fialed

Subscribers

People subscribed via source and target branches