File tree Expand file tree Collapse file tree 2 files changed +39
-0
lines changed Expand file tree Collapse file tree 2 files changed +39
-0
lines changed Original file line number Diff line number Diff line change @@ -14,6 +14,17 @@ register_hooks <- function() {
1414 new_ark_debug(base :: debugonce ),
1515 namespace = TRUE
1616 )
17+
18+ # We don't support `utils::recover()` in Ark, but the same functionality is
19+ # provided via the call stack pane of IDEs. So replace it by `browser()` so
20+ # that people can enter the debugger on error using the familiar
21+ # `options(error = recover)` gesture.
22+ rebind(
23+ " utils" ,
24+ " recover" ,
25+ browser ,
26+ namespace = TRUE
27+ )
1728 register_getHook_hook()
1829}
1930
Original file line number Diff line number Diff line change @@ -892,6 +892,34 @@ Are you calling `readline()` or `menu()` from `options(error = )`?
892892}
893893
894894#[ test]
895+ fn test_execute_request_error_recover ( ) {
896+ let frontend = DummyArkFrontend :: lock ( ) ;
897+
898+ let code = r#"
899+ f <- function() g()
900+ g <- function() h()
901+ h <- function() stop("foo")
902+ options(error = recover)
903+ "# ;
904+ frontend. execute_request_invisibly ( code) ;
905+
906+ frontend. send_execute_request ( "f()" , ExecuteRequestOptions :: default ( ) ) ;
907+ frontend. recv_iopub_busy ( ) ;
908+ let input = frontend. recv_iopub_execute_input ( ) ;
909+ assert_eq ! ( input. code, "f()" ) ;
910+
911+ // We set up the call stack to show a simple `error_handler()`
912+ frontend. recv_iopub_stream_stdout ( "Called from: error_handler()\n " ) ;
913+
914+ assert ! ( frontend. recv_iopub_execute_error( ) . contains( "foo" ) ) ;
915+
916+ frontend. recv_iopub_idle ( ) ;
917+ assert_eq ! (
918+ frontend. recv_shell_execute_reply_exception( ) ,
919+ input. execution_count
920+ ) ;
921+ }
922+
895923/// Install a SIGINT handler for shutdown tests. This overrides the test runner
896924/// handler so it doesn't cancel our test.
897925fn install_sigint_handler ( ) {
You can’t perform that action at this time.
0 commit comments