You are here: Elements > Methods > Programming Exceptions

Programming Exceptions

If you need to throw an exception (in the C++ sense) in your method, you may use either of two facilities intended for the purpose:

throw CFdFrameException("<error message>");

throw CFdFieldException("<error message>");

As the names imply, the first form aborts decoding of the entire current frame while the second merely aborts decoding of the current field. The parameter to the exception is a string explaining the cause of the exception that will be displayed in the Decode Pane.

Here is an example:

RETRIEVING_DATA

METHOD __DivideInteger__

/* Divides the current field value by an integer constant */

CODE

if (i64Param1 == 0)

{

throw CFdFieldException("Divide by zero error. Integer parameter is zero.");

i64FieldValue = -1;

}

else i64FieldValue = i64CurrentField / i64Param1;

ENDCODE

PARAM "Constant value to divide by" int64