diff options
Diffstat (limited to 'src/main/java/exceptions/VSProtocolException.java')
| -rw-r--r-- | src/main/java/exceptions/VSProtocolException.java | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/src/main/java/exceptions/VSProtocolException.java b/src/main/java/exceptions/VSProtocolException.java new file mode 100644 index 0000000..3af22f1 --- /dev/null +++ b/src/main/java/exceptions/VSProtocolException.java @@ -0,0 +1,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; + } +}
\ No newline at end of file |
