brodieG / unitizer

Easy R Unit Tests
Other
39 stars 6 forks source link

Capture and Prompt on Interrupt #277

Closed brodieG closed 3 years ago

brodieG commented 3 years ago

Based on:

https://milesmcbain.micro.blog/2021/06/10/debugging-cantrip-from.html

https://twitter.com/LukeTierney4/status/1402975719286738944?s=20

brodieG commented 3 years ago

Might it be possible to capture the browser exist signal too?

Update: no, it doesn't seem so. Q just calls jump_to_top_level.

brodieG commented 3 years ago

This seems to work:

time <- Sys.time()
time2
withRestarts(
  withCallingHandlers({
      readline('hello')
    },
    interrupt = function(e) {
      time2 <<- Sys.time()
      invokeRestart('interrupted')
    }
  ),
  interrupted=function(e) readline('hi again')
)