mirror of
https://github.com/abapGit/abapGit.git
synced 2025-04-30 20:03:20 +08:00
Refactor zcx_abapgit_exception
- Replace `split_text_to_symsg` with standard code - Replace loop + concat with builtin function
This commit is contained in:
parent
a8cb44d548
commit
2c797618ec
|
@ -104,11 +104,6 @@ CLASS zcx_abapgit_exception DEFINITION
|
|||
|
||||
CONSTANTS c_generic_error_msg TYPE string VALUE `An error occurred (ZCX_ABAPGIT_EXCEPTION)`.
|
||||
|
||||
CLASS-METHODS split_text_to_symsg
|
||||
IMPORTING
|
||||
!iv_text TYPE string
|
||||
RETURNING
|
||||
VALUE(rs_msg) TYPE symsg .
|
||||
METHODS save_callstack .
|
||||
METHODS itf_to_string
|
||||
IMPORTING
|
||||
|
@ -307,32 +302,21 @@ CLASS zcx_abapgit_exception IMPLEMENTATION.
|
|||
itf_text = lt_itf
|
||||
text_stream = lt_stream.
|
||||
|
||||
LOOP AT lt_string INTO lv_string.
|
||||
IF sy-tabix = 1.
|
||||
rv_result = lv_string.
|
||||
ELSE.
|
||||
CONCATENATE rv_result lv_string
|
||||
INTO rv_result
|
||||
SEPARATED BY cl_abap_char_utilities=>newline.
|
||||
ENDIF.
|
||||
|
||||
ENDLOOP.
|
||||
rv_result = concat_lines_of(
|
||||
table = lt_string
|
||||
sep = cl_abap_char_utilities=>newline ).
|
||||
|
||||
ENDMETHOD.
|
||||
|
||||
|
||||
METHOD raise.
|
||||
|
||||
DATA lv_text TYPE string.
|
||||
|
||||
IF iv_text IS INITIAL.
|
||||
lv_text = c_generic_error_msg.
|
||||
cl_message_helper=>set_msg_vars_for_clike( c_generic_error_msg ).
|
||||
ELSE.
|
||||
lv_text = iv_text.
|
||||
cl_message_helper=>set_msg_vars_for_clike( iv_text ).
|
||||
ENDIF.
|
||||
|
||||
split_text_to_symsg( lv_text ).
|
||||
|
||||
raise_t100(
|
||||
ii_log = ii_log
|
||||
ix_previous = ix_previous
|
||||
|
@ -439,22 +423,4 @@ CLASS zcx_abapgit_exception IMPLEMENTATION.
|
|||
ENDLOOP.
|
||||
|
||||
ENDMETHOD.
|
||||
|
||||
|
||||
METHOD split_text_to_symsg.
|
||||
|
||||
DATA ls_msg TYPE symsg.
|
||||
|
||||
cl_message_helper=>set_msg_vars_for_clike( iv_text ).
|
||||
ls_msg-msgv1 = sy-msgv1.
|
||||
ls_msg-msgv2 = sy-msgv2.
|
||||
ls_msg-msgv3 = sy-msgv3.
|
||||
ls_msg-msgv4 = sy-msgv4.
|
||||
|
||||
" Set syst using generic error message
|
||||
MESSAGE e001(00) WITH ls_msg-msgv1 ls_msg-msgv2 ls_msg-msgv3 ls_msg-msgv4 INTO null.
|
||||
|
||||
rs_msg = ls_msg.
|
||||
|
||||
ENDMETHOD.
|
||||
ENDCLASS.
|
||||
|
|
|
@ -406,7 +406,7 @@ CLASS ltcl_split_text IMPLEMENTATION.
|
|||
ENDMETHOD.
|
||||
METHOD test_set_msg_vars.
|
||||
|
||||
zcx_abapgit_exception=>split_text_to_symsg( iv_text ).
|
||||
cl_message_helper=>set_msg_vars_for_clike( iv_text ).
|
||||
|
||||
cl_abap_unit_assert=>assert_equals( act = sy-msgv1
|
||||
exp = is_msg-v1 ).
|
||||
|
|
Loading…
Reference in New Issue
Block a user