Permalink
Browse files

Add informative error messages

  • Loading branch information...
1 parent bd286ed commit e10a5044c6c7acaebfe296bfcaa611f8720539f8 @hadley committed Apr 11, 2009
Showing with 8 additions and 1 deletion.
  1. +1 −0 NEWS
  2. +7 −1 R/ply-list.r
View
1 NEWS
@@ -9,6 +9,7 @@ plyr 0.1.6 (2008-XX-XX) ---------------------------------------------------
* all ply functions deal more elegantly when given function names: can supply a vector of function names, and name is used as label in output
* ddply: first variable now varies slowest as you'd expect
* massive speed ups for splitting large arrays, in a similar way to data frames
+* first attempt at informative error messages
plyr 0.1.5 (2008-02-23) ---------------------------------------------------
View
@@ -41,7 +41,13 @@ llply <- function(.data, .fun = NULL, ..., .progress = "none") {
for(i in seq_len(n)) {
piece <- pieces[[i]]
- res <- .fun(piece, ...)
+
+ res <- try(.fun(piece, ...))
+ if (inherits(res, "try-error")) {
+ piece <- capture.output(print.default(piece))
+ stop("with piece ", i, ": \n", piece, call. = FALSE)
+ }
+
if (!is.null(res)) result[[i]] <- res
progress$step()
}

0 comments on commit e10a504

Please sign in to comment.