(commandLine string, exitCode int)
| 96 | } |
| 97 | |
| 98 | func InterpretCommandResult(commandLine string, exitCode int) ExitCodeInterpretation { |
| 99 | if exitCode == 0 { |
| 100 | return ExitCodeInterpretation{false, "Success (exit 0)"} |
| 101 | } |
| 102 | |
| 103 | base := ResolveBaseCommand(commandLine) |
| 104 | if base == "" { |
| 105 | return ExitCodeInterpretation{true, fmt.Sprintf("Exit code %d", exitCode)} |
| 106 | } |
| 107 | table, ok := exitCodeTables[base] |
| 108 | if ok && table != nil { |
| 109 | specific := table[exitCode] |
| 110 | if specific != nil { |
| 111 | return *specific |
| 112 | } |
| 113 | } |
| 114 | |
| 115 | if exitCode < 0 { |
| 116 | return ExitCodeInterpretation{true, "Process terminated by a signal or parent context cancellation"} |
| 117 | } |
| 118 | return ExitCodeInterpretation{true, fmt.Sprintf("Error (exit code %d)", exitCode)} |
| 119 | } |
| 120 | |
| 121 | func FormatExitCode(commandLine string, exitCode int) string { |
| 122 | interpretation := InterpretCommandResult(commandLine, exitCode) |
no test coverage detected