diff --git a/package.json b/package.json index 7475ef1e..3921cc4e 100644 --- a/package.json +++ b/package.json @@ -18,8 +18,8 @@ "@abaplint/cli": "^2.113.108", "@abaplint/database-pg": "^2.10.24", "@abaplint/database-sqlite": "^2.10.24", - "@abaplint/runtime": "^2.10.34", - "@abaplint/transpiler-cli": "^2.10.34", + "@abaplint/runtime": "^2.10.37", + "@abaplint/transpiler-cli": "^2.10.37", "0x": "^5.8.0" } } diff --git a/src/kernel/kernel_create_data_handle.clas.abap b/src/kernel/kernel_create_data_handle.clas.abap index 7b7478cf..597babf1 100644 --- a/src/kernel/kernel_create_data_handle.clas.abap +++ b/src/kernel/kernel_create_data_handle.clas.abap @@ -31,7 +31,9 @@ ENDCLASS. CLASS kernel_create_data_handle IMPLEMENTATION. METHOD call. - ASSERT handle IS BOUND. + IF handle IS NOT BOUND. + RAISE EXCEPTION TYPE cx_sy_ref_is_initial. + ENDIF. WRITE '@KERNEL if (dref.constructor.name === "FieldSymbol") {'. WRITE '@KERNEL dref = dref.getPointer();'. diff --git a/src/tcp/cl_apc_tcp_client_manager.clas.locals_imp.abap b/src/tcp/cl_apc_tcp_client_manager.clas.locals_imp.abap index fb5a6bdf..049e4856 100644 --- a/src/tcp/cl_apc_tcp_client_manager.clas.locals_imp.abap +++ b/src/tcp/cl_apc_tcp_client_manager.clas.locals_imp.abap @@ -63,8 +63,8 @@ CLASS lcl_client IMPLEMENTATION. * WRITE '@KERNEL console.dir(data);'. WRITE '@KERNEL await this.mo_handler.get().if_apc_wsp_event_handler$on_message({i_message: msg});'. WRITE '@KERNEL });'. - WRITE '@KERNEL this.client.on("end", async () => {this.mo_handler.get().if_apc_wsp_event_handler$on_close();});'. - WRITE '@KERNEL this.client.on("error", async (e) => {this.mo_handler.get().if_apc_wsp_event_handler$on_error();});'. + WRITE '@KERNEL this.client.on("end", async () => {this.mo_handler.get().if_apc_wsp_event_handler$on_close({"i_reason": "connection closed"});});'. + WRITE '@KERNEL this.client.on("error", async (e) => {console.dir("IF_APC_WSP_CLIENT~CONNECT"); console.dir(e); this.mo_handler.get().if_apc_wsp_event_handler$on_error({"i_reason": e.toString()});});'. WRITE '@KERNEL await new Promise(resolve => this.client.once("connect", resolve));'. ENDMETHOD. diff --git a/src/tcp/if_apc_wsp_event_handler.intf.abap b/src/tcp/if_apc_wsp_event_handler.intf.abap index 85f0e18f..8d4d5a2b 100644 --- a/src/tcp/if_apc_wsp_event_handler.intf.abap +++ b/src/tcp/if_apc_wsp_event_handler.intf.abap @@ -2,9 +2,12 @@ INTERFACE if_apc_wsp_event_handler PUBLIC. METHODS on_open. METHODS on_message - IMPORTING i_message TYPE REF TO if_apc_wsp_message. + IMPORTING + i_message TYPE REF TO if_apc_wsp_message. - METHODS on_close. + METHODS on_close + IMPORTING + i_reason TYPE string. METHODS on_error IMPORTING diff --git a/test/cl_apc_tcp_client_manager.clas.testclasses.abap b/test/cl_apc_tcp_client_manager.clas.testclasses.abap index 2b719b5f..eac6e55f 100644 --- a/test/cl_apc_tcp_client_manager.clas.testclasses.abap +++ b/test/cl_apc_tcp_client_manager.clas.testclasses.abap @@ -2,6 +2,7 @@ CLASS lcl_handler DEFINITION FINAL. PUBLIC SECTION. INTERFACES if_apc_wsp_event_handler. DATA message TYPE xstring. + DATA error_reason TYPE string. ENDCLASS. CLASS lcl_handler IMPLEMENTATION. @@ -19,7 +20,7 @@ CLASS lcl_handler IMPLEMENTATION. ENDMETHOD. METHOD if_apc_wsp_event_handler~on_error. - WRITE / 'on_error'. + error_reason = i_reason. ENDMETHOD. ENDCLASS. @@ -30,6 +31,7 @@ CLASS ltcl_tcp DEFINITION FOR TESTING RISK LEVEL HARMLESS DURATION MEDIUM FINAL. METHODS port_80 FOR TESTING RAISING cx_static_check. METHODS port_443 FOR TESTING RAISING cx_static_check. + METHODS on_error FOR TESTING RAISING cx_static_check. ENDCLASS. @@ -79,4 +81,31 @@ CLASS ltcl_tcp IMPLEMENTATION. test_port( '443' ). ENDMETHOD. + METHOD on_error. + + DATA lo_handler TYPE REF TO lcl_handler. + DATA li_client TYPE REF TO if_apc_wsp_client. + DATA ls_frame TYPE if_abap_channel_types=>ty_apc_tcp_frame. + DATA li_message_manager TYPE REF TO if_apc_wsp_message_manager. + DATA li_message TYPE REF TO if_apc_wsp_message. + + CREATE OBJECT lo_handler. + + ls_frame-frame_type = if_apc_tcp_frame_types=>co_frame_type_fixed_length. + ls_frame-fixed_length = 10. + + li_client = cl_apc_tcp_client_manager=>create( + i_host = 'somethingerror.org' + i_port = '12345' + i_frame = ls_frame + i_event_handler = lo_handler ). + + " li_client->connect( ). + + " cl_abap_unit_assert=>assert_equals( + " act = lo_handler->error_reason + " exp = 'todo' ). + + ENDMETHOD. + ENDCLASS. \ No newline at end of file