mirror of
https://github.com/abapGit/abapGit.git
synced 2025-04-30 20:03:20 +08:00
Decouple XML from UI factory (#4873)
This commit is contained in:
parent
553d1f2319
commit
e74c68e204
|
@ -28,23 +28,23 @@ CLASS zcl_abapgit_xml DEFINITION
|
|||
PRIVATE SECTION.
|
||||
|
||||
METHODS error
|
||||
IMPORTING ii_parser TYPE REF TO if_ixml_parser
|
||||
RAISING zcx_abapgit_exception.
|
||||
IMPORTING
|
||||
!ii_parser TYPE REF TO if_ixml_parser
|
||||
RAISING
|
||||
zcx_abapgit_exception .
|
||||
METHODS display_version_mismatch
|
||||
RAISING zcx_abapgit_exception.
|
||||
METHODS show_parser_errors
|
||||
IMPORTING ii_parser TYPE REF TO if_ixml_parser.
|
||||
RAISING
|
||||
zcx_abapgit_exception .
|
||||
METHODS raise_exception_for
|
||||
IMPORTING
|
||||
ii_error TYPE REF TO if_ixml_parse_error
|
||||
!ii_error TYPE REF TO if_ixml_parse_error
|
||||
RAISING
|
||||
zcx_abapgit_exception.
|
||||
|
||||
zcx_abapgit_exception .
|
||||
ENDCLASS.
|
||||
|
||||
|
||||
|
||||
CLASS zcl_abapgit_xml IMPLEMENTATION.
|
||||
CLASS ZCL_ABAPGIT_XML IMPLEMENTATION.
|
||||
|
||||
|
||||
METHOD constructor.
|
||||
|
@ -84,13 +84,7 @@ CLASS zcl_abapgit_xml IMPLEMENTATION.
|
|||
METHOD error.
|
||||
|
||||
IF ii_parser->num_errors( ) <> 0.
|
||||
|
||||
IF zcl_abapgit_ui_factory=>get_gui_functions( )->gui_is_available( ) = abap_true.
|
||||
show_parser_errors( ii_parser ).
|
||||
ELSE.
|
||||
raise_exception_for( ii_parser->get_error( 0 ) ).
|
||||
ENDIF.
|
||||
|
||||
raise_exception_for( ii_parser->get_error( 0 ) ).
|
||||
ENDIF.
|
||||
|
||||
IF mv_filename IS INITIAL.
|
||||
|
@ -141,6 +135,22 @@ CLASS zcl_abapgit_xml IMPLEMENTATION.
|
|||
ENDMETHOD.
|
||||
|
||||
|
||||
METHOD raise_exception_for.
|
||||
DATA lv_message TYPE string.
|
||||
|
||||
lv_message = |XML parser error: { ii_error->get_reason( ) }, | &&
|
||||
|Line { ii_error->get_line( ) } | &&
|
||||
|Col. { ii_error->get_column( ) }|.
|
||||
|
||||
IF mv_filename IS NOT INITIAL.
|
||||
lv_message = lv_message && | File { mv_filename }|.
|
||||
ENDIF.
|
||||
|
||||
zcx_abapgit_exception=>raise( lv_message ).
|
||||
|
||||
ENDMETHOD.
|
||||
|
||||
|
||||
METHOD to_xml.
|
||||
* will render to codepage UTF-16
|
||||
|
||||
|
@ -168,67 +178,4 @@ CLASS zcl_abapgit_xml IMPLEMENTATION.
|
|||
ENDIF.
|
||||
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD show_parser_errors.
|
||||
|
||||
DATA lv_error TYPE i.
|
||||
DATA lv_column TYPE string.
|
||||
DATA lv_line TYPE string.
|
||||
DATA lv_reason TYPE string.
|
||||
DATA lv_txt1 TYPE string.
|
||||
DATA lv_txt2 TYPE string.
|
||||
DATA lv_txt3 TYPE string.
|
||||
DATA lv_txt4 TYPE string.
|
||||
DATA lv_times TYPE i.
|
||||
DATA li_error TYPE REF TO if_ixml_parse_error.
|
||||
|
||||
lv_times = ii_parser->num_errors( ).
|
||||
|
||||
DO lv_times TIMES.
|
||||
lv_error = sy-index - 1.
|
||||
li_error = ii_parser->get_error( lv_error ).
|
||||
|
||||
lv_column = li_error->get_column( ).
|
||||
lv_line = li_error->get_line( ).
|
||||
lv_reason = li_error->get_reason( ).
|
||||
|
||||
IF mv_filename IS NOT INITIAL.
|
||||
lv_txt1 = |File: { mv_filename }|.
|
||||
lv_txt2 = |Column: { lv_column }|.
|
||||
lv_txt3 = |Line: { lv_line }|.
|
||||
lv_txt4 = lv_reason.
|
||||
ELSE.
|
||||
lv_txt1 = |Column: { lv_column }|.
|
||||
lv_txt2 = |Line: { lv_line }|.
|
||||
lv_txt3 = lv_reason.
|
||||
CLEAR lv_txt4.
|
||||
ENDIF.
|
||||
|
||||
CALL FUNCTION 'POPUP_TO_INFORM'
|
||||
EXPORTING
|
||||
titel = 'Error from XML parser'
|
||||
txt1 = lv_txt1
|
||||
txt2 = lv_txt2
|
||||
txt3 = lv_txt3
|
||||
txt4 = lv_txt4.
|
||||
ENDDO.
|
||||
|
||||
ENDMETHOD.
|
||||
|
||||
|
||||
METHOD raise_exception_for.
|
||||
DATA lv_message TYPE string.
|
||||
|
||||
lv_message = |XML parser error: { ii_error->get_reason( ) }, | &&
|
||||
|Line { ii_error->get_line( ) } | &&
|
||||
|Col. { ii_error->get_column( ) }|.
|
||||
|
||||
IF mv_filename IS NOT INITIAL.
|
||||
lv_message = lv_message && | File { mv_filename }|.
|
||||
ENDIF.
|
||||
|
||||
zcx_abapgit_exception=>raise( lv_message ).
|
||||
|
||||
ENDMETHOD.
|
||||
|
||||
ENDCLASS.
|
||||
|
|
Loading…
Reference in New Issue
Block a user