From 2d49a905377bf8aea265efadd2c90d36326801f9 Mon Sep 17 00:00:00 2001 From: Jakob Richter Date: Tue, 18 Dec 2018 10:34:12 +0100 Subject: [PATCH] add helpfull error message --- R/r6_class.R | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/R/r6_class.R b/R/r6_class.R index 6579f51..8bf9bbc 100644 --- a/R/r6_class.R +++ b/R/r6_class.R @@ -476,8 +476,13 @@ R6Class <- encapsulate(function(classname = NULL, public = list(), stop("All elements of public, private, and active must be named.") allnames <- c(names(public), names(private), names(active)) - if (any(duplicated(allnames))) - stop("All items in public, private, and active must have unique names.") + if (anyDuplicated(allnames)) { + stop( + "All items in public, private, and active must have unique names. ", + "Non unique names: ", + paste(allnames[duplicated(allnames)], collapse = ", " ) + ) + } if ("clone" %in% allnames) stop("Cannot add a member with reserved name 'clone'.")