Exception Handling

This chapter describes handling methods for exceptions that occur in X-UP as well as methods for handling ErrorCode and ErrorMsg in a Nexacro application's callback function.

Exception Handling Method

This section describes handling methods for exceptions that occur in a legacy and X-UP model logic class as well as X-UP Engine.

일반적인 SAP RFC 모델

An exception that occurs in a model's SAP RFC invoke can be handled in the following methods.

Pass ErrorCode and ErrorMsg When an Exception Occurs

If an error occurs in an SAP RFC invoke, the passed exception is thrown, and logic is interrupted. However, this is a case in which the error code is not -1 and a random error code is trying to be passed.
In this case, the error code can be passed by executing the following code using the SAP RFC invoke's Exception tab.

if(e instanceof AutomationFailException) {
	AutomationFailException exception = (AutomationFailException) e;
	exception.setErrorCode(-9999);
	throw exception;
} else {
	AutomationFailException exception = new AutomationFailException(e.getMessage(), e);
	exception.setErrorCode(-9999);
	throw exception;
}

Ignore When an Exception Occurs

An InvokeSkip exception can be created and thrown for the following cases: 1. If invoke processing is interrupted and the next logic must be processed due to an error;2. If an exception occurs in an SAP RFC invoke;3. If logic is interrupted after running an SAP RFC invoke and a UserMethod must be executed immediately.

InvokeSkip invokeSkipException = new InvokeSkip(e.getMessage(), e);
throw invokeSkipException;

The ErrorCode and ErrorMsg can be output to the UI as follows:

globalParameterSet.getParameter("ErrorCode").setValue(new Integer(-999));
globalParameterSet.getParameter("ErrorMsg").setValue("consumption data failed.");
InvokeSkip invokeSkipException = new InvokeSkip(e.getMessage(), e);

throw invokeSkipException;

Throw When an Exception Occurs

No specific handling is required if an exception occurs in an invoke, the model logic is interrupted, and the error is output immediately.

ErrorCode and ErrorMsg Handling

This section describes a method for handling ErrorCode and ErrorMsg with a Nexacro application's callback function.

If ErrorCode and ErrorMsg Are Not Handled

If ErrorCode and ErrorMsg are not handled by a developer, X-UP handles them as follows:

ErrorCode and ErrorMsg Handling

ErrorCode and ErrorMsg are handled in the model logic as follows:

  1. Create ErrorCode and ErrorMsg name variables in a model.

  1. Set the desired ErrorCode and ErrorMsg values in the variables during UserMethod or exception handling.

globalParameterSet.getParameter("ErrorCode").setValue(new Integer(-999));
globalParameterSet.getParameter("ErrorMsg").setValue("consumption data failed.");

Modify Invoke's Additional Exception Handling

Additional exceptions can be handled if an exception occurs in a modify invoke.

The following is a RowSkip example.

throw new RowSkip("ignore exception", e);

The onExceptionOccurred(ParameterSet globalParameterSet, Throwable e, InvokingErrorInfo errInfo) method in the above image is called when an error occurs while executing an invoke.

The following is a description of the method's parameter: