Consultor Eletrônico



Kbase 6587: Understanding ERROR HANDLING and error impact in PROGRESS
Autor   Progress Software Corporation - Progress
Acesso   Público
Publicação   5/10/1998
Understanding ERROR HANDLING and error impact in PROGRESS

910927-kw001DRAFT COPY - Under review and edit.

INTRODUCTION
============

This Progress Software Technical Support knowledgebase entry
describes how PROGRESS handles errors. For example, it
describes the types of errors you may encounter, how you
can anticipate the action PROGRESS will take, and how to
override this default handling.


WHO YOU NEED TO DO THIS
=======================

To develop the most effcient and correct error handling in your
applications, you need to understand which action PROGRESS takes on
different error conditions. Based on this knowledge, you can
decide whether or not you want to override this default handling
by your code.


TYPE OF ERRORS
==============

This section groups types of error into catagories. It also
contains a table that lists error types, error, and result of
the error. Then it describes the default way PROGRESS handles
these results. Finally it shows a procedure to use to test other
errors not described here.

1. System Error
- machine crash
- software error

2. Procedure-Generated Error
- execution error like:
- a record find fails
- a procedure tries to create a duplicate entry in a unique
index

3. User Caused
- the user presses a key that tells PROGRESS to do error or endkey
processing

4. Stop Key
- DOS : CTRL-BREAK
- OS/2 : CTRL-BREAK
- UNIX : CRTL-C
- BTOS/CTOS: ACTION-CANCEL
- VMS : CTRL-C

5. Other

Use the table on the next page to determine the consequences of
the most common errors, and the procedure "error.p" to test the
consequences of a procedure-generated error you do not find in the
table.

Table 1: Common Errors RESULT *

W
E a
E n C r
r d S r n
r k t a i
o e o s n
Type Error r y p h g
---- --------------------------------------- - - - - -
1 System error (a) x x

2 Array subscript out of range x
2 Unique record find fails x
2 Find FIRST/LAST record fails x
2 Find NEXT/PREV record fails x
2 Create duplicate record, unique index x
2 Data-type conversion fails x
2 Input file not found x
2 Procedure to be run not found x
2 File delete-validation fails x
2 Input validation fails (b)
2 Wrong input values in functions like: x
ENTRY, DATE, DECIMAL, INTEGER, ROUND,
TRUNCATE, SQRT, RANDOM, MODULE, FILL,
LOG
2 Unmatched (new) shared frames, x
buffers variables
2 CONNECT an already connected database x
2 DISCONNECT a not connected database x
2 Trying to access not connected database x
gives Compile Error or if you use
the STOP statement
3 Press a key defined as ERROR x
3 Press a key defined as ENDKEY x
3 Press END-ERROR key (c) x x

4 Press STOP key x

5 EOF or . encountered in INPUT FROM x
5 OS-escape fails no Progress
handling


Notes: (a) You may be returned to the operating system, or if serious,
your machine may crash.
(b) Automatic validation within an INSERT, UPDATE or PROMPT-FOR
statement.
(c) If it is the FIRST screen iteration of a block iteration,
PROGRESS does ENDKEY processing of the current iteration
of the block, otherwise PROGRESS does ERROR processing.


* Refer to the following table for the way PROGRESS handles
these results by default.

Use the following procedure to dtermine the consequences of
any error you can not find in Table 1.

/* error.p */

REPEAT /* which be default means:
ON ERROR UNDO, RETRY ON ENDKEY UNDO, LEAVE */ :

IF RETRY THEN DO:
MESSAGE "Repeat block being retried - ERROR processing".
RETURN.
END.

/* statement(s) to be tested,
no blocks with error or endkey properties */

END.

MESSAGE "Repeat block ended - ENDKEY processing".


Table 2: PROGRESS Defaults for Error Handling
----------------------------------------------------------------------

ERROR - Looks for the closest block that has the "error" property,
i.e., a REPEAT/FOR EACH/DO IN ERROR/PROCEDURE block
- Performs an UNDO, RETRY on that block

ENDKEY - Looks for the closet block that has the "endkey" property,
i.e., a REPEAT/FOR EACH/DO ON ENDKEY/PROCEDURE block
- Performs an UNDO, LEAVE on that block

STOP - Undoes the current transaction and returns control to the
startup procedure if one is still active, otherwise to the
editor.

WARNING - Writes a warning only. you can avoid this warning message
by using f.i. NO-ERROR, IF CONNECTED etc.

----------------------------------------------------------------------

However, no rule is without an exception!

To protect against INFINITE LOOPS, PROGRESS performs the following
actions unless you have specified an "IF RETRY .." test to
take care of the block retrial yourself:

UNDO,NEXT instead of an UNDO,RETRY within a FOR EACH block
UNDO,LEAVE instead of an UNDO,RETRY within a REPEAT block
UNDO,LEAVE instead of an UNDO,NEXT within a REPEAT block


HOW TO OVERRIDE PROGRESS' DEFAULT ERROR HANDLING
================================================

Use the ON ERROR and ON ENDKEY statements to modify the error/endkey
processing of a FOR EACH/REPEAT/PROCEDURE block or to add error/endkey
properties to a DO block.

Use the ON <key> ERROR, ON <key> ENDKEY, ON <key> END-ERROR to tell
PROGRESS which keys you want to raise error conditions.

perform the UNDO,LEAVE as explicitly specified nor an UNDO,RETRY! You
will rather stay in the UPDATE statement and be reprompted for
customer.

ONLINE PROCEDURES OR UTILITIES
==============================

None


REFERENCES TO WRITTEN DOCUMENTATION
===================================

Programming Handbook: Chapter 8 "Transactions and Error Processing"

Language Reference: ON statement, ON ERROR phrase, ON ENDKEY phrase

Progress Software Technical Support Note # 6587