net.kano.joscar.net
Class ConnProcessorExceptionEvent

java.lang.Object
  extended byConnProcessorExceptionEvent
Direct Known Subclasses:
FlapExceptionEvent

public class ConnProcessorExceptionEvent
extends java.lang.Object

An event that occurs when an exception is thrown somewhere in a ConnProcessor.


Field Summary
static java.lang.Object ERRTYPE_CMD_GEN
          An exception type indicating that an exception was thrown while converting a raw packet to a command object in a command factory.
static java.lang.Object ERRTYPE_CMD_WRITE
          An exception type indicating that an exception was thrown while writing a command to a stream.
static java.lang.Object ERRTYPE_CONNECTION_ERROR
          An exception type indicating that an exception was thrown while attempting to read from the attached input stream.
static java.lang.Object ERRTYPE_PACKET_LISTENER
          An exception type indicating that an exception was thrown while passing a packet event to a packet listener.
 
Constructor Summary
protected ConnProcessorExceptionEvent(java.lang.Object type, java.lang.Throwable exception, java.lang.Object reason)
          Creates a new exception event with the given properties.
 
Method Summary
 java.lang.Throwable getException()
          Returns the exception that was thrown.
 java.lang.Object getReason()
          Returns an object describing or providing more detail regarding the exception that was thrown.
 java.lang.Object getType()
          Returns the type of this exception, possibly indicating when or why this exception was thrown.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

ERRTYPE_CONNECTION_ERROR

public static final java.lang.Object ERRTYPE_CONNECTION_ERROR
An exception type indicating that an exception was thrown while attempting to read from the attached input stream. The "reason" (the value returned by getReason()) in this case will be null.


ERRTYPE_CMD_WRITE

public static final java.lang.Object ERRTYPE_CMD_WRITE
An exception type indicating that an exception was thrown while writing a command to a stream. In this case, the "reason" (the value returned by getReason()) will be the command object whose stream-writing method (like write) threw an exception.


ERRTYPE_CMD_GEN

public static final java.lang.Object ERRTYPE_CMD_GEN
An exception type indicating that an exception was thrown while converting a raw packet to a command object in a command factory. In this case, the "reason" (the value returned by getReason() will be the raw packet used in the command generation attempt which threw the exception).


ERRTYPE_PACKET_LISTENER

public static final java.lang.Object ERRTYPE_PACKET_LISTENER
An exception type indicating that an exception was thrown while passing a packet event to a packet listener.

Constructor Detail

ConnProcessorExceptionEvent

protected ConnProcessorExceptionEvent(java.lang.Object type,
                                      java.lang.Throwable exception,
                                      java.lang.Object reason)
Creates a new exception event with the given properties.

Parameters:
type - the type of the event, like ERRTYPE_CMD_GEN
exception - the exception that occurred, if any
reason - a "reason object" that describes why the given exception occurred, if any
Method Detail

getType

public final java.lang.Object getType()
Returns the type of this exception, possibly indicating when or why this exception was thrown. May be one of ERRTYPE_CONNECTION_ERROR, ERRTYPE_CMD_WRITE, ERRTYPE_CMD_GEN, and ERRTYPE_PACKET_LISTENER, but other classes may define their own types as well.

Returns:
the type of exception that was thrown

getException

public final java.lang.Throwable getException()
Returns the exception that was thrown.

Returns:
the thrown exception

getReason

public final java.lang.Object getReason()
Returns an object describing or providing more detail regarding the exception that was thrown. The type of this object varies with situation, but it may be a FlapPacketListener, for example, if that was the source of this exception, for example. The type of this value may change, so code such as the following is suggested for handling it:
if (e.getReason() instanceof Throwable) {
    ((Throwable) e.getReason()).printStackTrace();
} else {
    System.err.println(e.getReason());
}
     

Returns:
an object providing more information or detail on this exception

toString

public java.lang.String toString()