1check_spec <- function(spec) { 2 # Eventually should just be vec_assert() on partial_frame() 3 # Waiting for https://github.com/r-lib/vctrs/issues/198 4 5 if (!is.data.frame(spec)) { 6 stop("`spec` must be a data frame", call. = FALSE) 7 } 8 9 if (!has_name(spec, ".name") || !has_name(spec, ".value")) { 10 stop("`spec` must have `.name` and `.value` columns", call. = FALSE) 11 } 12 13 # Ensure .name and .value come first 14 vars <- union(c(".name", ".value"), names(spec)) 15 spec[vars] 16} 17 18wrap_error_names <- function(code) { 19 tryCatch( 20 code, 21 vctrs_error_names = function(cnd) { 22 abort( 23 c( 24 "Failed to create output due to bad names.", 25 "Choose another strategy with `names_repair`" 26 ), 27 parent = cnd 28 ) 29 } 30 ) 31} 32