tryCatch not catching error produced by install.packages within RStudio

后端 未结 3 1367
再見小時候
再見小時候 2021-01-22 02:02

Consider the following usage:

tryCatch(log(\"a\"), error = function(e) NULL)
#NULL

Now I\'m trying to do essentially the same, but in a more co

3条回答
  •  萌比男神i
    2021-01-22 03:02

    I'm going to suggest closing as off-topic because this is an RStudio problem. Basically, tryCatch is catching the error, but RStudio's error handler prints the error anyway. Thus the reason you're getting a return value:

    [[1]]
    NULL
    
    [[2]]
    NULL
    

    This means tryCatch works. RStudio just prints caught errors weirdly.

提交回复
热议问题