tryReturn <- function(expr, output, return_on_error, env = parent.frame()){
  if(isTRUE(return_on_error)){
    tryCatch(expr, error = function(e) error2return(e = e, output = output, env = env))
  } else {
    expr
  }
}
