After handling all the results of the command, your code should check the final return code from ct_results to see if errors are indicated.
Final return code values can be the following:
CS_END_RESULT – indicates a normal loop exit.
CS_CANCELED – indicates that results were canceled: ct_cancel(CS_CANCEL_ALL) or ct_cancel(CS_CANCEL_ATTN) was called while processing results.
CS_FAIL – indicates a serious client-side or network error, such as a communication failure or a memory shortage.