Allert for code note executed with cronR

Hello,

I am using cronR in Rstudio server and I am wondering if it is possible to set up some kind of alerts in case the script behind the cronR job encounters errors.

Do you have any suggestions?

Usually, you would do that with some sort of tryCatch mechanism. There is a function in base R that is doing that, but you can also take a look at purrr adverbs (safely, quietly ...).

Once you catch the error, you can do anything you like with it: send it to e-mail, log it, put error in DB, ...

According to the documentation (https://purrr.tidyverse.org/reference/safely.html), the purrr functions wrap other functions but now I would like to setup an alert for a whole rmarkdown script.

Is there something similar to wrap a whole rmarkdown script into a similar mechanism or other methods to record the errors from a rmarkdown script?

For example it is possible to insert into the rmarkdown chunks error=TRUE so that the script does not stop, in that case how can we safe the error messages?

I don't know if there is already a ready-made solution for this, but in general I still think you should think about wrapping your functions with some sort of try-catch mechanism. So, concretely, if you have code kinda like that:

```{r}
res <- function_that_can_fail()
```

then it is up to you to find a way to wrap it and then report the results. One example that comes to mind that does something similar is testthat, so you can use it for inspiration.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.