Bug #11255
Silent error gets overwritten in FINALLY no-error statement.
0%
Related issues
History
#1 Updated by Eduard Soltan 5 months ago
start.p
define temp-table ttTest
no-undo
field testNum as integer.
create ttTest.
ttTest.testNum = 5.
release ttTest.
def var h as handle.
def var a as logical init no.
h = temp-table ttTest:handle.
run test31.p (input table-handle h by-value, a) no-error. //// PLEASE NOTE no-error ON PROCEDURE CALL
MESSAGE "start" ERROR-STATUS:NUM-MESSAGES ERROR-STATUS:GET-MESSAGE(1).
test31.p
define input parameter table-handle httTest.
define input parameter undoError as logical no-undo.
def temp-table tt1 field f1 as int.
do on error undo, throw:
httTest:default-buffer-handle:find-first() no-error.
if httTest:default-buffer-handle:available then
httTest::testDesc = 4. // ERROR SHOULD BE RAISED HERE (testDesc field doesn't exist for passed table)
end.
FINALLY:
find first tt1 no-error.
message "FINALLY" ERROR-STATUS:NUM-MESSAGES ERROR-STATUS:GET-MESSAGE(1).
END FINALLY.
NO-ERROR will be converted in FWD into a ErrorManager.silent static method call, with the desired converted code as a lambda parameter. silent method will look something like this:
public void silent(Runnable code)
{
...
try
{
code.run()
}
catch (Error err)
{
...
}
finally
{
forwardPending(wa);
}
Any error that is raised in the converted code, will be registered wa.pendingErrorStatus. forwardPending method will move the info from wa.pendingErrorStatus to wa.errorStatus (from here it could be accessed by ERROR-STATUS handle).
Test breakdown¶
httTest::testDesc = 4. in my example will raised an error and will register the error it wa.pendingErrorStatus and will start unwind the stack. FINALLY block from start31.p will be executed, and another error will be thrown by find first tt1 no-error.
Once we call forwardPending method from ErrorManager.silent (of find first tt1 no-error.), it will move both errors from wa.pendingErrorStatus to wa.errorStatus and wa.pendingErrorStatus is cleared.
After that the control is return to start.p procedure, forwardPending method from ErrorManager.silent (of run test31.p (input table-handle h by-value, a) no-error.) is called. And wa.errorStatus is cleared by the empty wa.pendingErrorStatus.
#2 Updated by Eduard Soltan 5 months ago
- Related to Feature #9545: confirm/add table parameter support added
#3 Updated by Eduard Soltan 5 months ago
Output for previous test in OE:
FINALLY 1 ** FIND FIRST/LAST failed for table tt1. (565) start.p 1 ** BUFFER-FIELD testDesc was not found in buffer ttTest. (7351)
And output in FWD:
FINALLY 2 ** BUFFER-FIELD testDesc was not found in buffer ttTest. (7351) start.p 0
#4 Updated by Eduard Soltan 5 months ago
Perhaps a solution to this problem is to change wa.pendingErrorStatus into a stack of ErrorStatus. For every silent call to have its level on the stack, and at the end of the silent call to pop on level.
#5 Updated by Eduard Soltan 4 months ago
- Related to Bug #4891: Nested method calls ignore 'silent' (no-error) option. added