1
2
3
4
5
6
7
8
9
10
11 package org.eclipse.jgit.internal.diffmergetool;
12
13 import org.eclipse.jgit.util.FS.ExecutionResult;
14
15 import org.slf4j.Logger;
16 import org.slf4j.LoggerFactory;
17
18
19
20
21
22 public class ToolException extends Exception {
23
24 private final static Logger LOG = LoggerFactory
25 .getLogger(ToolException.class);
26
27 private final ExecutionResult result;
28
29 private final boolean commandExecutionError;
30
31
32
33
34 private static final long serialVersionUID = 1L;
35
36
37
38
39 public ToolException() {
40 this(null, null, false);
41 }
42
43
44
45
46
47 public ToolException(String message) {
48 this(message, null, false);
49 }
50
51
52
53
54
55
56
57
58
59 public ToolException(String message, ExecutionResult result,
60 boolean commandExecutionError) {
61 super(message);
62 this.result = result;
63 this.commandExecutionError = commandExecutionError;
64 }
65
66
67
68
69
70
71
72 public ToolException(String message, Throwable cause) {
73 super(message, cause);
74 result = null;
75 commandExecutionError = false;
76 }
77
78
79
80
81
82 public ToolException(Throwable cause) {
83 super(cause);
84 result = null;
85 commandExecutionError = false;
86 }
87
88
89
90
91 public boolean isResult() {
92 return result != null;
93 }
94
95
96
97
98 public ExecutionResult getResult() {
99 return result;
100 }
101
102
103
104
105 public boolean isCommandExecutionError() {
106 return commandExecutionError;
107 }
108
109
110
111
112 public String getResultStderr() {
113 if (result == null) {
114 return "";
115 }
116 try {
117 return new String(result.getStderr().toByteArray());
118 } catch (Exception e) {
119 LOG.warn("Failed to retrieve standard error output", e);
120 }
121 return "";
122 }
123
124
125
126
127 public String getResultStdout() {
128 if (result == null) {
129 return "";
130 }
131 try {
132 return new String(result.getStdout().toByteArray());
133 } catch (Exception e) {
134 LOG.warn("Failed to retrieve standard output", e);
135 }
136 return "";
137 }
138
139 }