Progress
Programming
Handbook
Overriding the Default Handling
When an error occurs, you might not want Progress to perform the default error processing. Rather than undoing and retrying the nearest block with the error property, you might want Progress to take some other action. For example, you might want Progress to leave the block or try the next iteration of the block. On the other hand, you might want Progress to undo a smaller amount of work. You have two techniques to change the error handling:
- Override the default error processing for a block by coding an explicit ON ERROR phrase on the nearest REPEAT, FOR EACH, or procedure block.
- Change the amount of work to be undone by adding the ON ERROR phrase to a DO block (thus giving the DO block the error property) or specifying a different block in the ON ERROR phrase.
Take the procedure
p
-error.p
, shown earlier, as an example. In this procedure, if the FIND statement fails, Progress undoes and retries that iteration of the REPEAT block. Suppose that you want to change that error processing to the following: if the FIND statement fails, undo the current iteration, and leave the REPEAT block. This is the modifiedp-error.p
procedure.In
p-error2.p
, the explicit ON ERROR phrase changes the handling of the ERROR condition:p-error2.p
![]()
In the following example, the ON ERROR phrase is added to a DO block to change the amount of work to be undone:
p-error3.p
![]()
Because the DO block has the error property, only the DO block is undone when an error occurs. Therefore, the UPDATE statement is not retried; instead, execution continues from the PROMPT–FOR statement.
In
p-error3.p
, you made Progress undo less than the default amount of work. Suppose you wanted Progress to undo more than the default amount of work. For example, inp-txn6.p
, shown earlier, if you make an error while entering an order–line (you pressed F9), you want to undo all the work done on the current order. To do this, you add a label to the outer REPEAT block and reference that label in the ON ERROR phrase of the inner REPEAT block:
Here, the inner REPEAT block explicitly says that, in the event of an error, Progress should undo not the current REPEAT block but the outer o–block REPEAT block. In addition, it tells Progress to retry the o–block block. This error processing applies to any kind of an error. That is, it happens if you press F9, or if there is some sort of processing error such as the FIND statement’s is unable to locate a record.
Copyright © 2004 Progress Software Corporation www.progress.com Voice: (781) 280-4000 Fax: (781) 280-4095 |