1 2abort_coercion <- function(x, to_type) { 3 x_type <- friendly_type_of(x) 4 if (!inherits(to_type, "AsIs")) { 5 to_type <- as_friendly_type(to_type) 6 } 7 abort(paste0("Can't convert ", x_type, " to ", to_type)) 8} 9