@@ -163,8 +163,7 @@ expect_warning <- function(object,
163163      ... ,
164164      inherit  =  inherit ,
165165      info  =  info ,
166-       label  =  label ,
167-       trace_env  =  caller_env()
166+       label  =  label 
168167    )
169168  } else  {
170169    act  <-  quasi_capture(enquo(object ), label , capture_warnings , ignore_deprecation  =  identical(regexp , NA ))
@@ -196,8 +195,7 @@ expect_message <- function(object,
196195      ... ,
197196      inherit  =  inherit ,
198197      info  =  info ,
199-       label  =  label ,
200-       trace_env  =  caller_env()
198+       label  =  label 
201199    )
202200  } else  {
203201    act  <-  quasi_capture(enquo(object ), label , capture_messages )
@@ -225,8 +223,7 @@ expect_condition <- function(object,
225223      ... ,
226224      inherit  =  inherit ,
227225      info  =  info ,
228-       label  =  label ,
229-       trace_env  =  caller_env()
226+       label  =  label 
230227    )
231228  } else  {
232229
@@ -256,18 +253,14 @@ expect_condition_matching <- function(base_class,
256253                                      label  =  NULL ,
257254                                      trace_env  =  caller_env(),
258255                                      error_call  =  caller_env()) {
259-   check_dots_used(error  =  function (cnd ) {
260-     warn(conditionMessage(cnd ), call  =  error_call )
261-   })
262- 
263256  matcher  <-  cnd_matcher(
264257    base_class ,
265258    class ,
266259    regexp ,
267260    ... ,
268261    inherit  =  inherit ,
269262    ignore_deprecation  =  base_class  ==  " warning"   &&  identical(regexp , NA ),
270-     error_call  =  trace_env 
263+     error_call  =  error_call 
271264  )
272265
273266  act  <-  quasi_capture(
@@ -301,6 +294,13 @@ cnd_matcher <- function(base_class,
301294  check_string(class , allow_null  =  TRUE , call  =  error_call )
302295  check_string(pattern , allow_null  =  TRUE , allow_na  =  TRUE , call  =  error_call )
303296
297+   if  (is.null(pattern ) &&  dots_n(... ) >  0 ) {
298+     cli :: cli_abort(
299+       " Can't specify {.arg ...} without {.arg pattern}."  ,
300+       call  =  error_call 
301+     )
302+   }
303+ 
304304  function (cnd ) {
305305    if  (! inherit ) {
306306      cnd $ parent  <-  NULL 
@@ -318,7 +318,17 @@ cnd_matcher <- function(base_class,
318318        return (FALSE )
319319      }
320320      if  (! is.null(pattern ) &&  ! isNA(pattern )) {
321-         grepl(pattern , conditionMessage(x ), ... )
321+         withCallingHandlers(
322+           grepl(pattern , conditionMessage(x ), ... ),
323+           error  =  function (e ) {
324+             cli :: cli_abort(
325+               " Failed to compare {base_class} to {.arg pattern}."  ,
326+               parent  =  e ,
327+               call  =  error_call 
328+             )
329+           }
330+         )
331+ 
322332      } else  {
323333        TRUE 
324334      }
0 commit comments