Difference between revisions of "READERNAME ExceptionHandler.java"

From RifidiWiki

Jump to: navigation, search
(invalidCommandError)
(malformedMessageError)
Line 49: Line 49:
 
See the above implementation for the commandNotFound.  The handling of this error will likely be the same, but the message might be slightly different.
 
See the above implementation for the commandNotFound.  The handling of this error will likely be the same, but the message might be slightly different.
  
==malformedMessageError==
+
==invalidCommandError==
 +
This exception is thrown in the [[CommandFlow|CommandAdapter]] if a command is in the reader.xml but is missing a required argument
 +
 
 
<pre>public abstract ArrayList<Object> malformedMessageError(ArrayList<Object> arg, CommandObject obj);</pre>
 
<pre>public abstract ArrayList<Object> malformedMessageError(ArrayList<Object> arg, CommandObject obj);</pre>
 +
 +
===Arguments===
 +
#arg - The incoming command
 +
#obj - The incoming command object
 +
 +
===Return Value===
 +
An array of objects where the first object in the array is a message to be sent back to the client.
 +
 +
===Reference Implementation===
 +
See the above implementation for the commandNotFound.  The handling of this error will likely be the same, but the message might be slightly different.

Revision as of 19:21, 1 February 2008

This class should extend GenericExceptionHandler.

It should override three methods:

CommandNotFoundError

This exception is thrown in the CommandAdapter if a command is sent to the reader that is not defined in the reader.xml

public abstract ArrayList<Object> commandNotFoundError(ArrayList<Object> arg, CommandObject obj);

Arguments

  1. arg - The incoming command
  2. obj - The incoming command object

Return Value

An array of objects where the first object in the array is a message to be sent back to the client.

Reference Implementation

This is the commandNotFoundError in the alien reader

	public ArrayList<Object> commandNotFoundError(ArrayList<Object> arg,
			CommandObject obj) {
		String message = "";
		for (Object i : arg) {
			message += i.toString();
		}
		message = "Error 1: Command not understood" + message;
		ArrayList<Object> returnValue = new ArrayList<Object>();
		returnValue.add(message);
                return returnValue;

	}

invalidCommandError

This exception is thrown in the CommandAdapter if a command is in the reader.xml but does has and invalid argument.

public abstract ArrayList<Object> invalidCommandError(ArrayList<Object> arg, String value, CommandObject obj);

Arguments

  1. arg - The incoming command
  2. obj - The incoming command object

Return Value

An array of objects where the first object in the array is a message to be sent back to the client.

Reference Implementation

See the above implementation for the commandNotFound. The handling of this error will likely be the same, but the message might be slightly different.

invalidCommandError

This exception is thrown in the CommandAdapter if a command is in the reader.xml but is missing a required argument

public abstract ArrayList<Object> malformedMessageError(ArrayList<Object> arg, CommandObject obj);

Arguments

  1. arg - The incoming command
  2. obj - The incoming command object

Return Value

An array of objects where the first object in the array is a message to be sent back to the client.

Reference Implementation

See the above implementation for the commandNotFound. The handling of this error will likely be the same, but the message might be slightly different.

Personal tools