-
Notifications
You must be signed in to change notification settings - Fork 32
Exception Handling
Home -> Developer Guide ->
The general approach to exception handling is to abort the run if an error occurs that makes it impossible to continue. All exception messages are localized via the Messages class. See Internationalization for more information.
When Cobol Check is able to detect a malformed Test Case, throw and log and halt processing so the user can correct their test suite. It may not always be possible for Cobol Check to detect this condition.
Example: One situation that has occurred with the proof of concept project is that a user may forget to write End-Mock to terminate a Mock definition. Without End-Mock, Cobol Check has no clear way to know when it has read all the Cobol statements the user has written to express the desired behavior of the mocked resource. The proof of concept just went on parsing without making any attempt to check the context. In Cobol Check, we want to look for signs that we have gone through all the statements related to the Mock. We can check for any Cobol Check keyword that would not occur inside a Mock definition, throw an exception and write to the log. We should halt execution, as we aren't sure the test suite accurately reflects the user's intent.
For errors that do not cause the run to halt, the standard is to throw and log, and catch at the appropriate level of abstraction.
An exception named PossibleInternalLogicErrorException is thrown in situations where code internal to Cobol Check attempts to invoke other Cobol Check code in a manner different from the design intent. The assumption is that a developer made a change to the logic that resulted in an illogical sequence of events internally. The code is complicated enough that we felt it useful to include this facility to help developers extricate themselves from unintended problems. End users should never see this exception. Its purpose is to help diagnose problems during development and testing.