error2return <- function(e, output, env){
  output <- c(output, list(e))
  warning("Error encountered, partial results returned: ", e, call. = FALSE)
  do.call("return", args = list(value = output), envir = env)
}
