Skip to content

File failures

Source: R/errors.R ยท Help: ?file_errors

Errors reading or writing a file. Both inherit from dataexcept_file_error. The underlying condition, typically the error or warning from the base R function that failed, goes in parent, and its message is appended to this one.

Usage

file_read_error(path, parent = NULL, call = NULL)

file_write_error(path, parent = NULL, call = NULL)

Arguments

path
The file path. A URL is redacted.
parent
The condition that caused this one, or NULL.
call
The call to report, or NULL.

Value

A condition inheriting from dataexcept_file_error.

Examples

read_orders <- function(path) {
  tryCatch(
    read.csv(path),
    error = function(e) stop(file_read_error(path, parent = e)),
    warning = function(w) stop(file_read_error(path, parent = w))
  )
}
tryCatch(
  read_orders(tempfile(fileext = ".csv")),
  dataexcept_file_error = function(e) conditionMessage(e)
)

See also

Other dataexcept errors: data_engineering_errors, data_frame_errors, data_quality_errors, job_errors, model_quality_errors, modelling_errors, pipeline_errors, service_errors, validation_error()