Merge lp:~mvo/snappy/snappy-more-errors-15.04 into lp:~snappy-dev/snappy/snappy-moved-to-github

Proposed by Michael Vogt
Status: Merged
Approved by: Michael Vogt
Approved revision: 441
Merged at revision: 486
Proposed branch: lp:~mvo/snappy/snappy-more-errors-15.04
Merge into: lp:~snappy-dev/snappy/snappy-moved-to-github
Diff against target: 34 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
Michael Vogt (community) Approve
John Lenton (community) Approve
Review via email: mp+260111@code.launchpad.net

Commit message

Improve error reporting for failed hooks.

Description of the change

Improve error reporting for failed hooks. We ran into a hook failure
issue that could only be diagnosed by having the output of the failing
aa-clickhook available.

To post a comment you must log in.
Revision history for this message
John Lenton (chipaca) wrote :

Looks good. Small nit, inline.

review: Approve
441. By Michael Vogt

snappy/errors.go: use %q for the output of failed hooks

Revision history for this message
Michael Vogt (mvo) wrote :

Thanks, I updated the branch.

review: Approve

Preview Diff

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

Subscribers

People subscribed via source and target branches