stop_if_dot_args: Stop with message if dot_args is a non-trivial list.

Description Usage Arguments Value Examples

View source: R/stop_if_dot_args.R

Description

Generate a stop with a good error message if the dots argument was a non-trivial list. Useful in writing functions that force named arguments.

Usage

1
stop_if_dot_args(dot_args, msg = "")

Arguments

dot_args

substitute(list(...)) from another function.

msg

character, optional message to prepend.

Value

NULL or stop()

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
f <- function(x, ..., inc = 1) {
   stop_if_dot_args(substitute(list(...)), "f")
   x + inc
}
f(7)
f(7, inc = 2)
tryCatch(
  f(7, 2),
  error = function(e) { print(e) }
)

WinVector/wrapr documentation built on Dec. 15, 2018, 11:08 a.m.