Skip to Content
3
Former Member
Mar 22, 2016 at 12:55 PM

Runtime error UNCAUGHT EXCEPTION "CX_SY_ILLEGAL_HANDLER" when triggering a message in the CATCH block

1531 Views

Hello SDNers,

I stumbled across a strange problem. When i raise a message in a CATCH [BEFORE UNWIND] block, the program aborts with a runtime error(RTE).

My code snippet:

REPORT zssa_demo_catch_exception.
CLASS lcx_exception DEFINITION INHERITING FROM cx_static_check.
ENDCLASS. CLASS exc_demo DEFINITION.
PUBLIC SECTION.
CLASS-METHODS: main. PRIVATE SECTION.
CLASS-METHODS:
meth1 RAISING lcx_exception,
meth2 RAISING resumable(lcx_exception).
ENDCLASS. CLASS exc_demo IMPLEMENTATION.
METHOD main. TRY .
exc_demo=>meth1( ).
exc_demo=>meth2( ). CATCH BEFORE UNWIND lcx_exception INTO DATA(exc).
MESSAGE exc TYPE 'S'. " Program aborts after this statement!!!
IF exc->is_resumable = abap_true.
RESUME.
ENDIF.
ENDTRY. cl_demo_output=>display(
EXPORTING
name = |Logs|
). ENDMETHOD.
METHOD meth1.
TRY .
RAISE EXCEPTION TYPE lcx_exception.
CLEANUP.
cl_demo_output=>write_text( |Cleanup in method| ).
ENDTRY.
ENDMETHOD.
METHOD meth2.
TRY.
RAISE RESUMABLE EXCEPTION TYPE lcx_exception.
cl_demo_output=>write_text( |Resuming method| ).
CLEANUP.
cl_demo_output=>write_text( |Cleanup in method| ).
ENDTRY.
cl_demo_output=>write_text( |Continue after TRY block in method| ).
ENDMETHOD.
ENDCLASS. START-OF-SELECTION.
exc_demo=>main( ).

The RTE states the following -

This text is linked to the exception ID UNSUPPORTED_CONTINUATION of the exception class CX_SY_ILLEGAL_HANDLER.

The MESSAGE statement terminates the handler (read: CATCH BLOCK), because the CLEANUP is triggered afterwards? This behaviour is specific to BEFORE UNWIND addition.

I checked the ABAP documentation on BEFORE UNWIND, but could not find any pointers. Also the statement -

If BEFORE UNWIND is used, after exception handling, and in all other cases before the exception handling.

seems to be confusing.

Can someone please clarify what exactly is going on?

BR,

Suhas

PS - I don't need a solution/workaround, i need to understand the behaviour 😊

Attachments