f<-function(x){if(x==10){stop("ten")}x}g<-function(x_max){result<-tryCatch(sapply(seq_len(x_max),f),error=function(e)NULL)if(is.null(result)){browser()}result}g(9)# This completes without an error.g(12)# This triggers the breakpoint.
In R, you can also define a global error handler (e.g., browser or recover):