Ubuntu Pastebin

Paste from Chipaca at Thu, 18 May 2017 11:47:46 +0000

Download as text
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
diff --git a/cmd/snap/error.go b/cmd/snap/error.go
index b785f26..11bdca7 100644
--- a/cmd/snap/error.go
+++ b/cmd/snap/error.go
@@ -61,7 +61,7 @@ func termSize() (width, height int) {
        return width, height
 }
 
-func fill(para string) string {
+func fill(para string, indent int) string {
        width, _ := termSize()
 
        if width > 100 {
@@ -74,22 +74,12 @@ func fill(para string) string {
        // work just for this.
        width--
 
-       // 3 is the %v\n, which will be present in any locale
-       indent := len(errorPrefix) - 3
        var buf bytes.Buffer
        doc.ToText(&buf, para, strings.Repeat(" ", indent), "", width-indent)
 
        return strings.TrimSpace(buf.String())
 }
 
-type filledError struct {
-       error
-}
-
-func (e filledError) Error() string {
-       return fill(e.error.Error())
-}
-
 func clientErrorToCmdMessage(snapName string, err *client.Error) (string, error) {
        // FIXME: using err.Message in user-facing messaging is not
        // l10n-friendly, and probably means we're missing ad-hoc messaging.
@@ -142,7 +132,9 @@ If you understand and want to proceed repeat the command including --classic.
        if usesSnapName {
                msg = fmt.Sprintf(msg, snapName)
        }
-       msg = fill(msg)
+       // 3 is the %v\n, which will be present in any locale
+       indent := len(errorPrefix) - 3
+       msg = fill(msg, indent)
        if isError {
                return "", errors.New(msg)
        }
Download as text