W
W0lfw00ds
Guest
I have a simple database which contains few tables and also a table for runtime errors. The idea is to save all occurred runtime errors into this table. The following demonstrates my use-case:
test1.p:
This doesn't work because of the error 'rethrow', which will
I don't want to save the error to some
I was thinking about doing it the following way:
test2.p:
Is there's any other simpler way to achieve this?
I wouldn't want to rely on
Continue reading...
test1.p:
Code:
BLOCK-LEVEL ON ERROR UNDO, THROW.
/* Some code which throws error */
RUN errorThrowingProcedure.
/* Catch any errors */
CATCH oError AS Progress.Lang.Error:
/* Write error to current database */
DEF BUFFER Errors_B1 FOR Errors.
CREATE Errors_B1.
ASSIGN Errors_B1.DateTimeTz = NOW
Errors_B1.ProgramName = PROGRAM-NAME(1)
Errors_B1.Message = oError:GetMessage(1).
/* Rethrow error to upper level */
UNDO, THROW oError.
END.
This doesn't work because of the error 'rethrow', which will
UNDO
the database changes.I don't want to save the error to some
NO-UNDO
variables or TEMP-TABLE
s and do the update later. I also don't want to spread this kind of error logic to multiple places depending on the ongoing transactions.I was thinking about doing it the following way:
test2.p:
Code:
BLOCK-LEVEL ON ERROR UNDO, THROW.
/* Some code which throws error */
RUN errorThrowingProcedure.
/* Catch any errors */
CATCH oError AS Progress.Lang.Error:
DEF VAR cCommandLine AS CHAR NO-UNDO.
DEF VAR cApplication AS CHAR NO-UNDO INIT "C:\Progress91E\bin\prowin32.exe".
DEF VAR cDatabase AS CHAR NO-UNDO INIT "MyDatabase".
DEF VAR cParams AS CHAR NO-UNDO.
DEF VAR cProcedure AS CHAR NO-UNDO INIT "C:\WRK91E\CreateError.p".
/* Params: 'Errors.DateTimeTz', 'Errors.ProgramName' and 'Errors.Message' */
cParams = SUBST("&1, &2, &3", NOW, PROGRAM-NAME(1), oError:GetMessage(1)).
cCommandLine = SUBST('&1 &2 -param "&3" -b -p &4', cApplication, cDatabase, cParams, cProcedure).
/* Write occured error to database */
OS-COMMAND NO-WAIT NO-CONSOLE VALUE(cCommandLine) NO-ERROR.
/* Rethrow error to upper level */
UNDO, THROW oError.
END.
Is there's any other simpler way to achieve this?
I wouldn't want to rely on
OS-COMMAND
if there's another easier or more robust way to invoke a new progress client within the current client process. The code above is also platform specific. I'd like to make it work on all possible platforms..Continue reading...