/
Subprocess (with messaging) Error Detection and Message Passing
Subprocess (with messaging) Error Detection and Message Passing
This snippet might be used when calling a subprocess equipped with messaging to get messages from the called subprocess and pass them to JSON string of the calling process.
Prolog, Metadata, Data, Epilog:
sProc = 'Process';
nRet = ExecuteProcess( sProc );
nSubProcessNumber = nSubProcessNumber + 1;
sMessage = INSRT('"sequence":"' | NumberToString( nSubProcessNumber ) | '", ', sProcessReturnCode, 2);
sMessageJSON = INSRT(' "message":', sMessage, 1);
sMultiMsg = Expand( '%sMultiMsg%' | If(LONG(sMultiMsg)=0, '', ', ') | '"' | NumberToString( nMultiMsgJSON ) | '":{%sMessageJSON%}' ); nMultiMsgJSON = nMultiMsgJSON + 1;
IF( nRet <> ProcessExitNormal % nProcessReturnCode = 0 );
nErrors = nErrors + 1;
sRet = NumberToString( nRet );
sMessage = Expand( 'Call to %sProc% has finished with errors (code = %sRet%).' );
sMessageJSON = INSRT(' "message":"', sMessage | '"', 1);
sMultiMsg = Expand( '%sMultiMsg%' | If(LONG(sMultiMsg)=0, '', ', ') | '"' | NumberToString( nMultiMsgJSON ) | '":{%sMessageJSON%}' ); nMultiMsgJSON = nMultiMsgJSON + 1;
LogOutput( cMsgErrorLevel, Expand( cMsgErrorContent ) );
ProcessBreak;
EndIF;