Progress Error

mallikasp

New Member
Hi All,

I heard that progress has a new function that capture any progress error like
**<table> already exists with <primary key>
and indicates that error has occured. Is anyone aware of this function??

Please let me know

Thanks,
Mallika
 

sdjensen

Member
Catch?

Code:
DEFINE VARIABLE iCust AS INTEGER NO-UNDO INITIAL 5000.
FIND Customer NO-LOCK WHERE Customer.CustNum = iCust. /* Will fail */
 
/* Won't execute because FIND fails */
MESSAGE "Customer found" VIEW-AS ALERT-BOX BUTTONS OK. 
 
/* The associated block for this CATCH block is the main block of the .p */
CATCH eSysError AS Progress.Lang.SysError:
  MESSAGE eSysError:GetMessage(1) VIEW-AS ALERT-BOX BUTTONS OK.
END CATCH.
 

GregTomkins

Active Member
I believe that the above syntax works OK but cannot be defined higher up in the call stack and resolved at runtime, the way one can do in Java. This makes it much less useful in P4GL than it would be in other languages with proper exception handling, IMHO. (Correct me if I'm wrong).

Eg. a typical case in Java (etc.) is to define a generic error handler right away, call a bunch of stuff, and when an error happens, the runtime searches back thru the call stack until it finds the generic handler. You can also add more specific handlers at appropriate places.

I don't think you can do this in P4GL, unless this has improved recently.
 

tamhas

ProgressTalk.com Sponsor
Look into the routine level error handling.

Nothing to keep you from starting out by defining a top level handler.
 

KrisM

Member
Routine level controls error handling on routine level only.
You still need to add an 'on error undo, throw' to every for each or repeat or other transaction block.
Otherwise, any error occurring inside that block will not be caught by the top level handler.
Or am I missing something ?
 

GregTomkins

Active Member
I don't think you are missing anything and as a result I think the TRY-CATCH stuff is not really all that useful. I'd appreciate being corrected, though.

In general I think Progress's error handling has always been atrocious, a real weakness (maybe the biggest weakness, apart from its obscurity) of Progress over almost every other language. I mean primarily in terms of the lack of detailed context that most error messages give you, but also in the spooky and arbitrary ways that it handles different error situations.
 
Top