| 172 | } |
| 173 | |
| 174 | func attachCommandLog(err error, logPath string, logOffset int64) error { |
| 175 | if err == nil { |
| 176 | return nil |
| 177 | } |
| 178 | text, readErr := readCommandLog(logPath, logOffset) |
| 179 | if readErr != nil { |
| 180 | return err |
| 181 | } |
| 182 | text = diagnostics.RedactAndBound(recentCommandError(text), maxDetachedCommandErrorBytes) |
| 183 | if text == "" { |
| 184 | return err |
| 185 | } |
| 186 | return fmt.Errorf("%w: stderr=%s", err, text) |
| 187 | } |
| 188 | |
| 189 | func readCommandLog(path string, offset int64) (text string, err error) { |
| 190 | file, err := os.Open(path) |