Handling errors
Put code in your programs that anticipates possible system or runtime problems. If you do not include such code, output data or files could be corrupted, and the user might not even be aware that there is a problem.
The error-handling code can take actions such as handling the situation, issuing a message, or halting the program. You might for example create error-detection routines for data-entry errors or for errors as your installation defines them. In any event, coding a warning message is a good idea.
Enterprise COBOL contains special elements to help you anticipate and correct error conditions:
- User-requested dumps
ON OVERFLOWinSTRINGandUNSTRINGoperationsON SIZE ERRORin arithmetic operations- Elements for handling input or output errors
ON EXCEPTIONorON OVERFLOWinCALLstatements- User-written routines for handling errors