Custom Error Codes and Messages

You may code your component to support customized error codes and error messages when Enhanced Error Handling is enabled.

When Enhanced Error Handling is enabled for a component, Isight captures failures in execution of the component and sets COMP_ERR_CODE parameter to -1; and COMP_ERR_MSG parameter to the message supplied by caught exception. If you want your component to return customized error codes and messages, you must set the values of these parameters in execute() method of the Executor class of your component.

To set a custom value to COMP_ERR_CODE and COMP_ERR_MSG parameters, you should use a code resembling the below code snippet:

boolean enhancedErrorHandlingEnabled = ((ScalarVariable)runtimeEnv.getProperty(DtComponent.PROPERTY_IS_ENHANCED_ERROR_HANDLING_ENABLED)).getValueObj().getAsBoolean();

If (enhancedErrorHandlingEnabled) {

ScalarVariable errorCode = (ScalarVariable)runtimeEnv.getContext().getParameterByTag(DtComponent.ERROR_CODE);

errorCode.getValueObj().setValue(Custom error code integer value );

ScalarVariable errorMsg = (ScalarVariable) runtimeEnv.getContext().getParameterByTag(DtComponent.ERROR_MESSAGE);

errorMsg.getValueObj().setValue("Custom error message string");

}