Browse Prior Art Database

Implicit RETRY in TRYCATCH blocks unless BREAK used

IP.com Disclosure Number: IPCOM000035581D
Original Publication Date: 2005-Jan-25
Included in the Prior Art Database: 2005-Jan-25
Document File: 2 page(s) / 33K

Publishing Venue

IBM

Abstract

Modern programming languages support the TRY/CATCH block for recovering from errors. However, it doesn't support the notion of fixing the error and then retrying the original block of code that failed. In order to do that the programmer would have to effectively repeat the code again within the CATCH block or wrap the TRY / CATCH block with a conditional control loop.

This text was extracted from a PDF file.
This is the abbreviated version, containing approximately 89% of the total text.

Page 1 of 2

Implicit RETRY in TRYCATCH blocks unless BREAK used

Described is a behavioral enhancement to the TRY / CATCH block to allow one or more retry attempts to be performed on the original code. The behavioral change is in the CATCH block in that it will automatically rexecute the TRY block unless a BREAK statement is encountered.

With this behavior change the CATCH block could effectively fix an error and the TRY would be executed again unless a BREAK statement was placed in the CATCH to terminate the retry attempt.

So now you have an implicit RETRY feature that is stopped via a BREAK statement, similar in concept to BREAKS used in SWITCH cases where the BREAK prevents the CASE from falling thru to the next CASE/DEFAULT statement.

As an example:

TRY {

if(x>100) throw BadXValueException;

if (y>100) throw BadYValueException; rSquared = x*x + y*y; if(rSquared>1000000) throw TooBigException; }

CATCH (BadXValueException) {

x=50; // implicit retry of TRY block }

CATCH (BadXValueException) {

x=50; // implicit retry of TRY block }

CATCH (TooBigException) { rSquared=1000000; break; //explicit termination of TRY block }

FINALLY {

    ...called when there is no catch or retry count exhausted }

The equivalent code using the control loop logic might be:

FOR (int iComplete=0; i<1; iComplete=0 ) {

1

Page 2 of 2

TRY {

if(x>100) throw BadXValueException;

if (y>100) throw BadYValueException; rSquared = x*x + y*y; iComplete++; }

CATCH (BadXValueException) { x=50

    CONTINUE; }

CATCH (BadXValue...