blob: 3af22f17211de50b02c360c15a2bac74bdc42758 (
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
|
package exceptions;
/**
* Exception thrown when there is an error in protocol execution or initialization.
* This includes protocol misconfiguration, invalid state transitions, or communication errors.
*
* @author Paul C. Buetow
*/
public class VSProtocolException extends VSSimulatorException {
/** The serial version uid */
private static final long serialVersionUID = 1L;
private final String protocolName;
/**
* Constructs a new protocol exception with the specified detail message.
*
* @param message the detail message
*/
public VSProtocolException(String message) {
super(message);
this.protocolName = null;
}
/**
* Constructs a new protocol exception for a specific protocol.
*
* @param protocolName the name of the protocol that encountered the error
* @param message the detail message
*/
public VSProtocolException(String protocolName, String message) {
super(String.format("Protocol '%s': %s", protocolName, message));
this.protocolName = protocolName;
}
/**
* Constructs a new protocol exception with the specified detail message and cause.
*
* @param protocolName the name of the protocol that encountered the error
* @param message the detail message
* @param cause the cause
*/
public VSProtocolException(String protocolName, String message, Throwable cause) {
super(String.format("Protocol '%s': %s", protocolName, message), cause);
this.protocolName = protocolName;
}
/**
* Gets the protocol name associated with this exception.
*
* @return the protocol name, or null if not specific to a protocol
*/
public String getProtocolName() {
return protocolName;
}
}
|