[rkward] packages/rkwarddev/R: improved error handling of rk.JS.header()

m.eik michalke meik.michalke at uni-duesseldorf.de
Sun Oct 11 13:03:27 UTC 2015


Git commit a6c1ff087c98f61ff34efded81f3ba2d1361ad51 by m.eik michalke.
Committed on 11/10/2015 at 12:57.
Pushed by meikm into branch 'master'.

improved error handling of rk.JS.header()

  - now gives more informative error messages that the previous stopifnot() calls

M  +6    -1    packages/rkwarddev/R/rk.JS.header.R

http://commits.kde.org/rkward/a6c1ff087c98f61ff34efded81f3ba2d1361ad51

diff --git a/packages/rkwarddev/R/rk.JS.header.R b/packages/rkwarddev/R/rk.JS.header.R
index c876615..112ddd0 100644
--- a/packages/rkwarddev/R/rk.JS.header.R
+++ b/packages/rkwarddev/R/rk.JS.header.R
@@ -51,10 +51,15 @@ rk.JS.header <- function(title, ..., level=NULL, guess.getter=FALSE, .add=list()
         functionName <- headerNames[[this.add]]
         content <- addToHeader[[this.add]]
         if(identical(functionName, "addFromUI")){
-          stopifnot(length(content) == 1)
+          if(length(content) != 1){
+            stop(simpleError("rk.JS.header: \"addFromUI\" must have exactly one value. please use several elements of the same name if needed!"))
+          } else {}
           content <- paste0("\"", id(content, js=FALSE), "\"")
         } else if(identical(functionName, "add")){
           stopifnot(length(content) == 2)
+          if(length(content) != 2){
+            stop(simpleError("rk.JS.header: \"add\" must have exactly two values. please use several elements of the same name if needed!"))
+          } else {}
           if(is.character(content[[2]])){
             value <- paste0("\"", content[[2]], "\"")
           } else if(is.XiMpLe.node(content[[2]])){



More information about the rkward-tracker mailing list