Resist this temptation.
Error handling is an integral part of any application. Don't just tack it on as an afterthought. Build it into your design, and into your code, from the very beginning.
Coding error messages is tedious. It's hard to pay close attention, and it's easy to miscode a character literal or a picture clause. Blunders which are hard to spot in the source code may be embarrassingly obvious when you see the actual message issued.
Faulty logic can be even more insidious. If you abend immediately upon detecting an error condition, you probably won't go too far wrong. But if you try to back out gracefully through several layers of code, or if you skip past a non-fatal error and continue processing, there are more opportunities for things to go wrong. Code designed for normal, valid data can do strange and unexpected things when it encounters errors.
Error-handling code is just like any other code: you can't trust it until you've tested it. So test it.
Some error conditions are easy to create. If your program reads an input file, it should test for such things as an empty file, cycle errors, missing header or trailer records, and wrong trailer counts. All you have to do is edit your input file in various ways and make sure your program responds correctly.
Other error conditions are harder to fake -- especially when you're reading complex and mysterious files from other applications. You may be able to insert temporary code to create error conditions artificially:
***** TEMPORARY CODE FOR TESTING RESPONSE TO ERROR IN JK104
IF INPUT-COUNT > 500
SET JKKS-FATAL TO TRUE.
***** END TEMPORARY CODE
Some error conditions are more difficult to fake, and unlikely to occur
in real life. If you have to jump through a lot of hoops to simulate
the error, it may not be worth it. Besides being a lot of work, the
creation of the error is likely to be as error-prone as the code for
handling it. Just stare at the code, think hard, and cross your
fingers.
This last suggestion is, of course, a judgement call. For JOCKEY it is a reasonable approach, if used sparingly. It is not an option for an application which cannot afford to make mistakes -- say, a fly-by-wire avionics system for an F-16.