R/errors.R

Defines functions container_error push_error build_error is_error is_docker_error_not_found

is_docker_error_not_found <- function(e) {
  inherits(e, "docker_error") && e$code == 404L
}


is_error <- function(e) {
  inherits(e, "condition")
}


build_error <- function(message) {
  ret <- list(message = message, call = NULL)
  class(ret) <- c("build_error", "error", "condition")
  ret
}


push_error <- function(message) {
  ret <- list(message = message, call = NULL)
  class(ret) <- c("push_error", "error", "condition")
  ret
}


container_error <- function(container, exit_status, cmd, image, out) {
  if (inherits(out, "docker_stream")) {
    err <- out[attr(out, "stream") == "stderr"]
    if (length(err) > 0L) {
      err <- paste0("\n", err, collapse = "")
    } else {
      err <- ""
    }
  } else {
    err <- paste0("\n", out)
  }
  msg <- sprintf(
    "Command '%s' in image '%s' returned non-zero exit status %s%s",
    paste(cmd, collapse = " "), image$name(), exit_status, err)
  ret <- list(container = container, exit_status = exit_status,
              cmd = cmd, image = image, out = out, message = msg)
  class(ret) <- c("container_error", "docker_error", "error", "condition")
  ret
}

Try the stevedore package in your browser

Any scripts or data that you put into this service are public.

stevedore documentation built on July 26, 2023, 5:35 p.m.