Connecting Apama Applications to External Components > Developing Custom Adapters > Java Codec Plug-in Development > The Codec Plug-in Development Specification for Java > Java codec exceptions
Java codec exceptions
CodecException is the exception class that should be thrown by a codec plug-in whenever the one of its methods is called and an error prevents the method from successfully completing — for example, a message that cannot be encoded or decoded because it has an invalid format.
A CodecException object always has an associated message, which is a String explaining the problem (this may include information about another exception that caused the CodecException to be thrown). There is also a code field that specifies the kind of error that occurred; the possible codes are defined as constants in the CodecException class:
/**
* Some unspecified internal error occurred
*/
public static final int INTERNALERROR = 1;
/**
* Couldn't encode an incoming normalized event
*/
public static final int ENCODINGFAILURE = 2;
/**
* Couldn't decode an incoming customer event
*/
public static final int DECODINGFAILURE = 3;
/**
* Trouble sending encoded event to transport
*/
public static final int TRANSPORTFAILURE = 4;
/**
* Trouble sending decoded event to Semantic Mapper
*/
public static final int MAPPINGFAILURE = 5;
/**
* Codec was passed an invalid property set
*/
public static final int BADPROPERTIES = 6;
Like the TransportException object, CodecException defines a number of constructors, to make it easy to set up the exception’s information quickly in different situations:
/**
* Constructs a CodecException from a string message describing the
* error, and assumes an error code of TRANSPORTFAILURE.
*
* @param message The cause of the error.
*/
public CodecException(String message) { ... }
/**
* Constructs a CodecException from a string message describing the
* error and a numeric code representing the class of error.
*
* @param message The cause of the error.
* @param code One of the CodecException error codes.
*/
public CodecException(String message, int code) { ... }
/**
* Constructs a CodecException from a string message describing the
* error, and an exception object that is the cause of the error. It
* assumes an error code of TRANSPORTFAILURE.
*
* @param message The cause of the error. This message will be suffixed
* with the message of the 'cause' exception.
* @param cause The exception object that caused the error.
*/
public CodecException(String message, Throwable cause) { ... }
/**
* Constructs a CodecException from a string message describing the
* error, a numeric code representing the class of error and an exception
* object that is the cause of the error.
*
* @param message The cause of the error. This message will be suffixed
* with the message of the 'cause' exception.
* @param cause The exception object that caused the error.
* @param code One of the CodecException error codes.
*/
public CodecException(String message, Throwable cause, int code) { ... }
Copyright © 2013-2015 Software AG, Darmstadt, Germany and/or Software AG USA Inc., Reston, VA, USA, and/or its subsidiaries and/or its affiliates and/or their licensors.
Use, reproduction, transfer, publication or disclosure is prohibited except as specifically provided for in your License Agreement with Software AG.