| 81 | } |
| 82 | |
| 83 | func (r *decryptGroupError) UserError() string { |
| 84 | var status string |
| 85 | if r.err == nil { |
| 86 | status = statusSuccess |
| 87 | } else { |
| 88 | status = statusFailed |
| 89 | } |
| 90 | header := fmt.Sprintf(`Group %s: %s`, r.groupName, status) |
| 91 | if r.err == nil { |
| 92 | return header |
| 93 | } |
| 94 | message := r.err.Error() |
| 95 | if userError, ok := r.err.(UserError); ok { |
| 96 | message = userError.UserError() |
| 97 | } |
| 98 | reader := prefixer.New(strings.NewReader(message), " ") |
| 99 | // Safe to ignore this error, as reading from a strings.Reader can't fail |
| 100 | errMsg, _ := io.ReadAll(reader) |
| 101 | return fmt.Sprintf("%s\n%s", header, string(errMsg)) |
| 102 | } |
| 103 | |
| 104 | type decryptKeyErrors []error |
| 105 | |