-
-
Notifications
You must be signed in to change notification settings - Fork 42
Closed
Labels
Description
Caller identification for error printing is made here:
Lines 42 to 44 in ca6632e
| get_caller <- function(n=1) { | |
| sub("\\.[[:alpha:]]+$", "", as.character(sys.call(-n-1))[[1]]) | |
| } |
So, for instance, we have this for R 3.6.x as well as 4.0.x:
trajectory() %>% log_(1)
#> Error: log_: 'message' is not a valid character or functionBut then, for R 4.1.x:
trajectory() %>% log_(1)
#> Error: check_args: 'message' is not a valid character or functionand R 4.2.x:
trajectory() %>% log_(1)
#> Error: stop: 'message' is not a valid character or functionwhich means that we cannot rely on a fixed stack position. It's better to perform a (limited) search, e.g.,
get_caller <- function(max.depth=10) {
for (i in seq_len(max.depth)) {
fun <- as.character(sys.call(-i-1)[[1]])
if (grepl("\\.(simmer|trajectory)$", fun))
return(strsplit(fun, ".", fixed=TRUE)[[1]][1])
}
return("")
}Reactions are currently unavailable