blob: 7862cf596794fc655b3cb1cd0333b9d260939073 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
|
/*
* Copyright (C) 2018-2021, Andre Bossert <andre.bossert@siemens.com>
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Distribution License v. 1.0 which is available at
* https://www.eclipse.org/org/documents/edl-v10.php.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
package org.eclipse.jgit.internal.diffmergetool;
import org.eclipse.jgit.util.FS.ExecutionResult;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* Tool exception for differentiation.
*
*/
public class ToolException extends Exception {
private final static Logger LOG = LoggerFactory
.getLogger(ToolException.class);
private final ExecutionResult result;
/**
* the serial version UID
*/
private static final long serialVersionUID = 1L;
/**
*
*/
public ToolException() {
super();
result = null;
}
/**
* @param message
* the exception message
*/
public ToolException(String message) {
super(message);
result = null;
}
/**
* @param message
* the exception message
* @param result
* the execution result
*/
public ToolException(String message, ExecutionResult result) {
super(message);
this.result = result;
}
/**
* @param message
* the exception message
* @param cause
* the cause for throw
*/
public ToolException(String message, Throwable cause) {
super(message, cause);
result = null;
}
/**
* @param cause
* the cause for throw
*/
public ToolException(Throwable cause) {
super(cause);
result = null;
}
/**
* @return true if result is valid, false else
*/
public boolean isResult() {
return result != null;
}
/**
* @return the execution result
*/
public ExecutionResult getResult() {
return result;
}
/**
* @return the result Stderr
*/
public String getResultStderr() {
try {
return new String(result.getStderr().toByteArray());
} catch (Exception e) {
LOG.warn(e.getMessage());
}
return ""; //$NON-NLS-1$
}
/**
* @return the result Stdout
*/
public String getResultStdout() {
try {
return new String(result.getStdout().toByteArray());
} catch (Exception e) {
LOG.warn(e.getMessage());
}
return ""; //$NON-NLS-1$
}
}
|