R/type_errors.R

Defines functions throw_type_bounds_error throw_type_check_error

throw_type_check_error <- function(signature, name) {
  stop(errorCondition(class = c("TypeError"),
    sprintf(
      "Type of parameter '%s' does not match signature `%s`",
      name,
      deparse(signature)
    )
  ))
}

throw_type_bounds_error <- function(bounds) {
  stop(errorCondition(class = c("TypeParameterError", "TypeError"),
    sprintf("Type parameter '%s' not satisfied", deparse(bounds))
  ))
}
dgkf/typewriter documentation built on March 17, 2022, 5:16 p.m.