Skip to Content
-1
Aug 21, 2023 at 08:41 AM

Catching an Exception is sometimes not working.

75 Views Last edit Aug 22, 2023 at 02:50 AM 5 rev

data: l_string type string.


try.
perform ztest_form_creat_sqlexception.
catch cx_sy_open_sql_db into data(err1).
l_string = | case A-1: { err1->get_text( ) }|.
catch cx_root into data(err2). " catched here
l_string = | case A-2: { err2->get_text( ) }|.
endtry.
message l_string type 'I' display like 'E'.


try.
perform ztest_form_creat_dynexception.
catch cx_sy_send_dynpro_no_receiver into data(err3). " catched here
l_string = | case B-1: { err3->get_text( ) }|.
catch cx_root into data(err4).
l_string = | case B-2: { err4->get_text( ) }|.
endtry.
message l_string type 'I' display like 'E'.

exit.


form ztest_form_creat_sqlexception.
raise exception type cx_sy_open_sql_db.
endform.

form ztest_form_creat_dynexception.
raise exception type cx_sy_send_dynpro_no_receiver.
endform.

With the code above, I get case A-2 and case B-1.

Is there any reason for having the different catching points with each exceptions?

Because if I cannot know the reason, I need to catch all excaptions with cx_root.

Thanks.