ohmm
Class DefaultErrorHandler

java.lang.Object
  extended by ohmm.DefaultErrorHandler
All Implemented Interfaces:
ErrorHandler

public class DefaultErrorHandler
extends java.lang.Object
implements ErrorHandler

Default OHMM error handler.

Logs errors to errorStream, if non-null, and then does System.exit(1) iff exitOnError.

This implementation funnels everything through error(String, Exception), so subclasses can override only that if they so choose.

Author:
Marsette A. Vona

Field Summary
protected  java.io.PrintStream errorStream
          The stream to which error messages are printed or null for none.
protected  boolean exitOnError
          Whether to exit immediately on any error.
 
Constructor Summary
DefaultErrorHandler()
          Covers DefaultErrorHandler(boolean, PrintStream), does not exit on error and prints to System.err.
DefaultErrorHandler(boolean exitOnError, java.io.PrintStream errorStream)
          Make a new DefaultErrorHandler.
DefaultErrorHandler(java.io.PrintStream errorStream)
          Covers DefaultErrorHandler(boolean, PrintStream), does not exit on error.
 
Method Summary
 void closingError(java.io.IOException e)
          Called if there was a problem closing communication.
protected  void error()
          covers error(String, Exception), no msg and no exception
protected  void error(java.lang.Exception e)
          covers error(String, Exception), no msg
protected  void error(java.lang.String msg)
          covers error(String, Exception), no exception
protected  void error(java.lang.String msg, java.lang.Exception e)
          Generic error handler, all other handlers funnel here.
 void initializationError(java.io.IOException e)
          Called if there was a problem initializing communication.
 void interrupted(java.lang.InterruptedException e)
          Called if we're interrupted while waiting.
 void readException(java.io.IOException e)
          Called when there's an IOException on recv.
 void setErrorStream(java.io.PrintStream errorStream)
          Set the stream to which error messages are logged or null for none.
 void setExitOnError(boolean exitOnError)
          Set whether to exit immediately on any error (after printing an error message to errorStream).
 void timeout()
          Called when we timeout on a recv.
 void writeException(java.io.IOException e)
          Called when there's an IOException on send.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

errorStream

protected java.io.PrintStream errorStream

The stream to which error messages are printed or null for none.


exitOnError

protected boolean exitOnError

Whether to exit immediately on any error.

Constructor Detail

DefaultErrorHandler

public DefaultErrorHandler(boolean exitOnError,
                           java.io.PrintStream errorStream)

Make a new DefaultErrorHandler.

Parameters:
exitOnError - whether to exit on error
errorStream - the stream to which error messages are printed or null for none

DefaultErrorHandler

public DefaultErrorHandler(java.io.PrintStream errorStream)

Covers DefaultErrorHandler(boolean, PrintStream), does not exit on error.


DefaultErrorHandler

public DefaultErrorHandler()

Covers DefaultErrorHandler(boolean, PrintStream), does not exit on error and prints to System.err.

Method Detail

setExitOnError

public void setExitOnError(boolean exitOnError)

Set whether to exit immediately on any error (after printing an error message to errorStream).

Parameters:
exitOnError - whether to exit immediately on any error

setErrorStream

public void setErrorStream(java.io.PrintStream errorStream)

Set the stream to which error messages are logged or null for none.

Parameters:
errorStream - the stream to which error messages are logged or null for none

initializationError

public void initializationError(java.io.IOException e)

Called if there was a problem initializing communication.

Specified by:
initializationError in interface ErrorHandler
Parameters:
e - the exception, or null if none

closingError

public void closingError(java.io.IOException e)

Called if there was a problem closing communication.

Specified by:
closingError in interface ErrorHandler
Parameters:
e - the exception, or null if none

writeException

public void writeException(java.io.IOException e)

Called when there's an IOException on send.

Specified by:
writeException in interface ErrorHandler
Parameters:
e - the exception

readException

public void readException(java.io.IOException e)

Called when there's an IOException on recv.

Specified by:
readException in interface ErrorHandler
Parameters:
e - the exception

interrupted

public void interrupted(java.lang.InterruptedException e)

Called if we're interrupted while waiting.

Specified by:
interrupted in interface ErrorHandler
Parameters:
e - the exception

timeout

public void timeout()

Called when we timeout on a recv.

Specified by:
timeout in interface ErrorHandler

error

protected void error(java.lang.String msg,
                     java.lang.Exception e)

Generic error handler, all other handlers funnel here.

Displays a message if errorStream is not null, then calls System.exit(1) if exitOnError.

Parameters:
msg - the message to display or null to use the default msg "error"
e - the exception to display or null for none

error

protected void error(java.lang.String msg)
covers error(String, Exception), no exception


error

protected void error(java.lang.Exception e)
covers error(String, Exception), no msg


error

protected void error()
covers error(String, Exception), no msg and no exception