loop_until_done: Error Swallower

Description Usage Arguments Examples

View source: R/loop_until_done.R

Description

Recursive helper function to reinvoke other function passed as parameter if some unexpected error occurs. However, if the invoked function is buggy and always throws some error in its internal execution, it'll generate a infinite loop. So be careful and just use this function to handle errors when exceptions seldom occur. For instance, it would be useful in some function which communicates over a network and thus depends on external resources that could fail unexpectedly.

Usage

1

Arguments

func

function to be monitored and restarted if some unexpected error happens.

...

additional paramaters to be delegated to func.

Examples

1
2
3
4
5
6
get_some_network_resource <- function(param1, param2) {}

 loop_until_done <- function(
   func = get_some_network_resource,
   param1 = param1,
   param2 = param2)

rladeira/rutils documentation built on May 27, 2019, 9:28 a.m.