public final class ProtocolException extends SmartInspectException
This exception can be thrown by several Protocol methods like the Protocol.connect(), Protocol.disconnect() or Protocol.writePacket methods when an error has occurred.
See below for an example on how to obtain detailed information in the Error event in the SmartInspect class about the protocol which caused the error.
Note: This class is not guaranteed to be threadsafe. Example:
import com.gurock.smartinspect.*;
class Listener extends SmartInspectAdapter
{
public void onError(ErrorEvent e)
{
System.out.println(e.getException());
if (e.getException() instanceof ProtocolException)
{
ProtocolException pe = (ProtocolException) e.getException();
// A ProtocolException provides additional information
// about the occurred error besides the normal exception
// message, like, for example, the name of the protocol
// which caused this error.
System.out.println(pe.getProtocolName());
System.out.println(pe.getProtocolOptions());
}
}
}
public class ErrorHandling
{
public static void main(String[] args)
{
// Register our event handler for the error event.
SiAuto.si.addListener(new Listener());
try
{
// And force a connection error.
SiAuto.si.setConnections("file(filename=c:\\\\)");
}
catch (InvalidConnectionsException e)
{
// This catch block is useless. It won't be reached
// anyway, because a connection error doesn't result
// in a Java exception. The SmartInspect Java library
// uses the Error event for this purpose.
}
SiAuto.si.setEnabled(true);
}
}
| Constructor and Description |
|---|
ProtocolException(String e)
Creates and initializes a ProtocolException instance.
|
| Modifier and Type | Method and Description |
|---|---|
String |
getProtocolName()
Returns the name of the protocol which caused this exception
|
String |
getProtocolOptions()
Returns the options of the protocol which caused this exception.
|
void |
setProtocolName(String name)
Sets the name of the protocol which caused this exception.
|
void |
setProtocolOptions(String options)
Sets the options of the protocol which caused this exception.
|
addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toStringpublic ProtocolException(String e)
e - The error message which describes the exceptionpublic String getProtocolName()
public void setProtocolName(String name)
name - The name of the protocolpublic String getProtocolOptions()
public void setProtocolOptions(String options)
options - The options of the protocolCopyright © 2023. All rights reserved.