Class ProtocolException
- java.lang.Object
-
- java.lang.Throwable
-
- java.lang.Exception
-
- com.gurock.smartinspect.SmartInspectException
-
- com.gurock.smartinspect.protocols.ProtocolException
-
- All Implemented Interfaces:
Serializable
public final class ProtocolException extends SmartInspectException
This class is used to report any errors concerning the protocol classes.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); } }- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description ProtocolException(String e)Creates and initializes a ProtocolException instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description StringgetProtocolName()Returns the name of the protocol which caused this exceptionStringgetProtocolOptions()Returns the options of the protocol which caused this exception.voidsetProtocolName(String name)Sets the name of the protocol which caused this exception.voidsetProtocolOptions(String options)Sets the options of the protocol which caused this exception.-
Methods inherited from class java.lang.Throwable
addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
-
-
-
-
Constructor Detail
-
ProtocolException
public ProtocolException(String e)
Creates and initializes a ProtocolException instance.- Parameters:
e- The error message which describes the exception
-
-
Method Detail
-
getProtocolName
public String getProtocolName()
Returns the name of the protocol which caused this exception- Returns:
- The name of the protocol which caused this exception
-
setProtocolName
public void setProtocolName(String name)
Sets the name of the protocol which caused this exception.- Parameters:
name- The name of the protocol
-
getProtocolOptions
public String getProtocolOptions()
Returns the options of the protocol which caused this exception.- Returns:
- The options of the protocol which caused this exception
-
setProtocolOptions
public void setProtocolOptions(String options)
Sets the options of the protocol which caused this exception.- Parameters:
options- The options of the protocol
-
-