base::stop
will always give that warning if you call it with a condition (e.g. caught error from a tryCatch
) as its argument and supply call.
or domain
.
This is because of the check in base::stop
if (length(args) == 1L && inherits(args[[1L]], "condition")) {
....
if (nargs() > 1L) # give the warning
where args
is your ...
.
For the call.
argument, stop
takes this from the error object itself rather than from the call.
argument to stop
(hence the warning you are getting)::
stop(simpleError('achtung!'))
# Error: achtung!
stop(simpleError('achtung!'), call.=F) # gives the warning
# Error: achtung!
# In addition: Warning message:
# In stop(simpleError("achtung!"), call. = F) :
# additional arguments ignored in stop()
stop(simpleError('achtung!', call=call('f')))
# Error in f() : achtung!
Depending on how the error in your particular code is constructed, you can set call
to NULL
in the creation of the error to suppress it in the call to stop
.
You could either:
- modify your code that calls
stop(someConditionObject)
to just callstop
with that object's message (so that the call is not passed through) - modify your
stop
to test ifinherits(args[[1L]], "condition")
and set the call toNULL
ifcall.=F
to suppress it (error$call <- NULL
), and then callbase::stop(error)
without thecall.
argument.