File tree 3 files changed +69
-27
lines changed 3 files changed +69
-27
lines changed Original file line number Diff line number Diff line change @@ -2,7 +2,6 @@ package tfexec
2
2
3
3
import (
4
4
"context"
5
- "errors"
6
5
"fmt"
7
6
"os/exec"
8
7
"regexp"
@@ -216,29 +215,3 @@ type ExitError struct {
216
215
func (e * ExitError ) Unwrap () error {
217
216
return e .err
218
217
}
219
-
220
- func (e * ExitError ) Error () string {
221
- var out string
222
- ee , ok := e .err .(* exec.ExitError )
223
- if ok {
224
- out = fmt .Sprintf ("%q (pid %d) exited (code %d): %s" ,
225
- e .args ,
226
- ee .Pid (),
227
- ee .ExitCode (),
228
- ee .ProcessState .String ())
229
- if e .ctxErr != nil {
230
- out += fmt .Sprintf ("\n %s" , e .ctxErr )
231
- }
232
- } else {
233
- out = fmt .Sprintf ("%q exited: %s" , e .args , e .err .Error ())
234
- if e .ctxErr != nil && ! errors .Is (e .err , e .ctxErr ) {
235
- out += fmt .Sprintf ("\n %s" , e .ctxErr )
236
- }
237
- }
238
-
239
- if e .stderr != "" {
240
- out += fmt .Sprintf ("\n stderr: %q" , e .stderr )
241
- }
242
-
243
- return out
244
- }
Original file line number Diff line number Diff line change
1
+ // +build !go1.12,!go1.13
2
+
3
+ package tfexec
4
+
5
+ import (
6
+ "errors"
7
+ "fmt"
8
+ "os/exec"
9
+ )
10
+
11
+ func (e * ExitError ) Error () string {
12
+ var out string
13
+ ee , ok := e .err .(* exec.ExitError )
14
+ if ok {
15
+ out = fmt .Sprintf ("%q (pid %d) exited (code %d): %s" ,
16
+ e .args ,
17
+ ee .Pid (),
18
+ ee .ExitCode (),
19
+ ee .ProcessState .String ())
20
+ if e .ctxErr != nil {
21
+ out += fmt .Sprintf ("\n %s" , e .ctxErr )
22
+ }
23
+ } else {
24
+ out = fmt .Sprintf ("%q exited: %s" , e .args , e .err .Error ())
25
+ if e .ctxErr != nil && ! errors .Is (e .err , e .ctxErr ) {
26
+ out += fmt .Sprintf ("\n %s" , e .ctxErr )
27
+ }
28
+ }
29
+
30
+ if e .stderr != "" {
31
+ out += fmt .Sprintf ("\n stderr: %q" , e .stderr )
32
+ }
33
+
34
+ return out
35
+ }
Original file line number Diff line number Diff line change
1
+ // +build go1.12 go1.13
2
+
3
+ package tfexec
4
+
5
+ import (
6
+ "fmt"
7
+ "os/exec"
8
+ )
9
+
10
+ func (e * ExitError ) Error () string {
11
+ var out string
12
+ ee , ok := e .err .(* exec.ExitError )
13
+ if ok {
14
+ out = fmt .Sprintf ("%q (pid %d) exited (code %d): %s" ,
15
+ e .args ,
16
+ ee .Pid (),
17
+ ee .ExitCode (),
18
+ ee .ProcessState .String ())
19
+ if e .ctxErr != nil {
20
+ out += fmt .Sprintf ("\n %s" , e .ctxErr )
21
+ }
22
+ } else {
23
+ out = fmt .Sprintf ("%q exited: %s" , e .args , e .err .Error ())
24
+ if e .ctxErr != nil {
25
+ out += fmt .Sprintf ("\n %s" , e .ctxErr )
26
+ }
27
+ }
28
+
29
+ if e .stderr != "" {
30
+ out += fmt .Sprintf ("\n stderr: %q" , e .stderr )
31
+ }
32
+
33
+ return out
34
+ }
You can’t perform that action at this time.
0 commit comments