How can I get the error details with TRY…CATCH ?
LYCIA
Problem
If I use the TRY...CATCH statement I can get the error code using the SQLCA or STATUS variables but these do not return more detail such as function where the error occurred, lines where it occurred. How can I get this information?
Solution
Pass the STRING parameter which will contain a range of lines where an error may occur to the fn_handle_exception() function, and handle it inside.
Error lines in native Lycia error messages are available only in debug(unl) cache.
Fast release cache doesn’t contain such info by default. To turn it on, add QX_REL_LINE_INFO=1 to inet.env
There are two options to retrieve a full error message:
MAIN DEFINE err INTEGER CALL startlog("xxxx.log") TRY OPEN WINDOW w1 WITH FORM "yyyy" CATCH CALL fgl_getkey() END TRY END MAIN
or
MAIN DEFINE err INTEGER CALL startlog("xxxx.log") WHENEVER ANY ERROR CALL errorlog OPEN WINDOW w1 WITH FORM "yyyy" CALL fgl_getkey() END MAIN
To get the error text, use ERR_GET( )
Find more details on how to implement error logging in Lycia Online Tutorials
Related articles