@@ -356,8 +356,9 @@ compute_nesting_container_info <- function(x, condition) {
356356
357357# ------------------------------------------------------------------------------
358358
359- stop_matches <- function (class = NULL , ... , call = caller_env()) {
359+ stop_matches <- function (message = NULL , class = NULL , ... , call = caller_env()) {
360360 stop_vctrs(
361+ message = message ,
361362 class = c(class , " vctrs_error_matches" ),
362363 ... ,
363364 call = call
@@ -375,6 +376,27 @@ warn_matches <- function(message, class = NULL, ..., call = caller_env()) {
375376
376377# ------------------------------------------------------------------------------
377378
379+ stop_matches_overflow <- function (size , call ) {
380+ size <- format(size , scientific = FALSE )
381+
382+ # Pre-generating the message in this case because we want to use
383+ # `.internal = TRUE` and that doesn't work with lazy messages
384+ message <- c(
385+ " Match procedure results in an allocation larger than 2^31-1 elements." ,
386+ i = glue :: glue(" Attempted allocation size was {size}." )
387+ )
388+
389+ stop_matches(
390+ message = message ,
391+ class = " vctrs_error_matches_overflow" ,
392+ size = size ,
393+ call = call ,
394+ .internal = TRUE
395+ )
396+ }
397+
398+ # ------------------------------------------------------------------------------
399+
378400stop_matches_nothing <- function (i , needles_arg , haystack_arg , call ) {
379401 stop_matches(
380402 class = " vctrs_error_matches_nothing" ,
0 commit comments