-
Notifications
You must be signed in to change notification settings - Fork 25
TypeCobolErrorSyntax
- TCERR_INTRINSIC_TYPE Error are represented with the intrinsic type ErrorCode. This type is defined like this:
01 ErrorCode TYPEDEF STRONG.
05 code pic X(04).
-
TCERR_IMPLICIT_ERRORCODE_VAR All functions, procedures and procedure division of a program can access an implicit variable always named "ErrorCode". This variable is declared with a private scope (not GLOBAL or EXTERNAL). This variable is for internal use and to call other functions/procedure/program. This variable can't be received as a parameter.
-
TCERR_IMPLICIT_ERRORCODE_PARAM All functions and procedures have a special parameter named ErrorCode. If another parameter is also named "ErrorCode", there must be an error. All call to a function or procedure must pass this ErroCode variable. After the call to a function or procedure, you can then use the syntax:
Call getCurrentDate returning xxx
If getCurrentDate::ErrorCode not = OK
error, by default call the paragraph used to manage error.
Else
Ok, continue
End-if
-
TCERR_IMPLICIT_PARAGRAPH An paragraph used to manage error must be present in all programs, functions and procedures. By default, this paragraph is implicit and is always named
TC-STANDARD-ERROR-MANAGEMENT
. If another paragraph have the same name, there must be an error. -
TCERR_OVERRIDE_IMPLICIT_PARAGRAPH The implicit paragraph used to manage error can be changed. The sentence
error procedure is *MY-PARAGRAPH*
must be declared in identification division TODO specify exactly where -
TCERR_ERROR_AFTER_FUNCTION When a function is called an there is an error, the paragraph used to manage error must be called.
- TCERR_DECLARE_EXPECTED_ERRORS Function and procedure can declare ErrorCode that the caller should test. These are errors which callee know that they are likely to occur. Syntax to declare there ErrorCode is:
declare function MyFunction PUBLIC
input
returning
error ErrorCode::Code-NotFound ErrorCode::Code-DatabaseNotAvailable '7894'
end-declare
Error
keyword must be followed by either:
-
ErrorCode::Code 88 level values
-
Literal of length 4
-
TCERR_ERROR_INSIDE_CALL A call to a function or procedure can include code to manage errors.
Call myFunction input xxxx
returning xxxx
on error
when ErrorCode::Code-NotFound
xxx
when ErrorCode::Code-DatabaseNotAvailable
xxxx
when ErrorCode::Code-Fatal
when 'U748'
xxxx
when other
IMPLICIT_ERROR_PARAGRAPH
End-call
Note that when
clause can only contains a ErrorCode::Code 88 level values or a literal.
There is no link between error declared by the function or procedure and when clause specified in the callee.
Error declared by function or procedure are just a guide for the callee.
An IDE can use this declarations to autocomplete the on error
statement.
If not specified, the following on error
statement is implied:
on error
when other
IMPLICIT_ERROR_PARAGRAPH
Introduction
TypeCobol language
-
In a nutshell
-
TypeCobol concepts
TypeCobol Editor
(Type)Cobol parser API
TypeCobol architecture
- Glossary
- Main phases
- How to extend the grammar and semantic check (full example)
- File
- Text
- Code analysis steps
- Program class parser
- Type checker
- Error handler
- Grammars Composition
- Code generation
- Compilation process
(Type)Cobol concepts / reference doc
Contributing