nealrichardson commented on a change in pull request #10387:
URL: https://github.com/apache/arrow/pull/10387#discussion_r644285045
##########
File path: r/R/util.R
##########
@@ -110,3 +110,11 @@ handle_embedded_nul_error <- function(e) {
}
stop(e)
}
+
+is_writable_table <- function(x) {
+ inherits(x, c("data.frame", "ArrowTabular"))
+}
+
+attr(is_writable_table, "fail") <- function(call, env){
+ paste0(eval(substitute(substitute(y, env), list(y = call$x)))," is not an
object of class 'data.frame', 'RecordBatch', or 'Table'.")
Review comment:
I don't think that's bad because `x` is the name of the argument in
these functions. If the argument were named something else, it would use that
name:
```
> f <- function(zzz) {
assert_that(is_writable_table(zzz))
}
> f(letters)
Error: zzz is not an object of class 'data.frame', 'RecordBatch', or 'Table'.
> f(c("a", "b"))
Error: zzz is not an object of class 'data.frame', 'RecordBatch', or 'Table'.
```
This is how `assertthat` does it too. See
https://github.com/hadley/assertthat/blob/master/R/base-is.r for example.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]