free, go_page, ext error handler

This commit is contained in:
Alexander Tsybulsky 2019-03-19 18:08:43 +02:00 committed by Lars Hvam
parent 6eba7c8f53
commit 80f86bd005
4 changed files with 56 additions and 3 deletions

View File

@ -24,6 +24,13 @@ CLASS zcl_abapgit_gui DEFINITION
RAISING
zcx_abapgit_exception.
METHODS go_page
IMPORTING
io_page TYPE REF TO zif_abapgit_gui_renderable
iv_clear_stack TYPE abap_bool DEFAULT abap_true
RAISING
zcx_abapgit_exception.
METHODS back
IMPORTING
iv_to_bookmark TYPE abap_bool DEFAULT abap_false
@ -47,6 +54,12 @@ CLASS zcl_abapgit_gui DEFINITION
RAISING
zcx_abapgit_exception.
METHODS free.
EVENTS on_handle_error
EXPORTING
VALUE(io_exception) TYPE REF TO cx_root.
PROTECTED SECTION.
PRIVATE SECTION.
@ -229,6 +242,16 @@ CLASS ZCL_ABAPGIT_GUI IMPLEMENTATION.
ENDMETHOD.
METHOD free.
SET HANDLER me->on_event FOR mo_html_viewer ACTIVATION space.
mo_html_viewer->close_document( ).
mo_html_viewer->free( ).
FREE mo_html_viewer.
ENDMETHOD.
METHOD get_current_page_name.
IF mi_cur_page IS BOUND.
@ -255,6 +278,18 @@ CLASS ZCL_ABAPGIT_GUI IMPLEMENTATION.
ENDMETHOD.
METHOD go_page.
IF iv_clear_stack = abap_true.
CLEAR mt_stack.
ENDIF.
mi_cur_page = io_page.
render( ).
ENDMETHOD.
METHOD handle_action.
DATA: lx_exception TYPE REF TO zcx_abapgit_exception,
@ -310,8 +345,7 @@ CLASS ZCL_ABAPGIT_GUI IMPLEMENTATION.
ENDCASE.
CATCH zcx_abapgit_exception INTO lx_exception.
ROLLBACK WORK.
MESSAGE lx_exception TYPE 'S' DISPLAY LIKE 'E'.
RAISE EVENT on_handle_error EXPORTING io_exception = lx_exception.
CATCH zcx_abapgit_cancel ##NO_HANDLER.
" Do nothing = gc_event_state-no_more_act
ENDTRY.

View File

@ -61,6 +61,8 @@ CLASS ZCL_ABAPGIT_UI_FACTORY IMPLEMENTATION.
li_router TYPE REF TO zif_abapgit_gui_event_handler,
li_asset_man TYPE REF TO zif_abapgit_gui_asset_manager.
DATA lo_error_handler TYPE REF TO lcl_gui_error_handler.
IF go_gui IS INITIAL.
li_asset_man ?= init_asset_manager( ).
CREATE OBJECT li_router TYPE zcl_abapgit_gui_router.
@ -68,6 +70,8 @@ CLASS ZCL_ABAPGIT_UI_FACTORY IMPLEMENTATION.
EXPORTING
io_component = li_router
ii_asset_man = li_asset_man.
CREATE OBJECT lo_error_handler.
SET HANDLER lo_error_handler->on_gui_error FOR go_gui.
ENDIF.
ro_gui = go_gui.

View File

@ -0,0 +1,13 @@
CLASS lcl_gui_error_handler DEFINITION.
PUBLIC SECTION.
METHODS on_gui_error FOR EVENT on_handle_error OF zcl_abapgit_gui
IMPORTING
io_exception.
ENDCLASS.
CLASS lcl_gui_error_handler IMPLEMENTATION.
METHOD on_gui_error.
ROLLBACK WORK.
MESSAGE io_exception TYPE 'S' DISPLAY LIKE 'E'.
ENDMETHOD.
ENDCLASS.

View File

@ -128,7 +128,9 @@ ENDFORM.
FORM exit RAISING zcx_abapgit_exception.
CASE sy-ucomm.
WHEN 'CBAC'. "Back
IF zcl_abapgit_ui_factory=>get_gui( )->back( ) IS INITIAL.
IF zcl_abapgit_ui_factory=>get_gui( )->back( ) = abap_true. " end of stack
zcl_abapgit_ui_factory=>get_gui( )->free( ). " Graceful shutdown
ELSE.
LEAVE TO SCREEN 1001.
ENDIF.
ENDCASE.