New argument call for stopf() and warningf()#186
Conversation
|
Sadly, since we pass a condition object,
Codex suggest |
call. in stopf() and warningf()call for stopf() and warningf()
|
Encapsulation tests fail because previously we had > tryCatch(mlr3misc::stopf("c"), error = identity) |> str()
List of 1
$ message: chr "c"
- attr(*, "class")= chr [1:3] "Mlr3Error" "error" "condition"which now is: > tryCatch(mlr3misc::stopf("c"), error = identity) |> str()
List of 2
$ message: chr "c"
$ call : language doTryCatch(return(expr), name, parentenv, handler)
- attr(*, "class")= chr [1:3] "Mlr3Error" "error" "condition"However, compare this with normal > tryCatch(stop("c"), error = identity) |> str()
List of 2
$ message: chr "c"
$ call : language doTryCatch(return(expr), name, parentenv, handler)
- attr(*, "class")= chr [1:3] "simpleError" "error" "condition"Recommendation: Update encapsulation tests and leave new implementation as is. |
|
With this change, Base behavior: f <- function(msg, call) stop(msg, call. = call)
f("a", TRUE)
# Error in f("a", TRUE) : a
f("a", FALSE)
# Error: aOld behavior: f <- function(msg) stopf(msg)
f("a")
# Error: aNew behavior: f <- function(msg, call) stopf(msg, call = call)
f("a", TRUE)
# Error in f("a", TRUE) : a
f("a", FALSE)
# Error: aYou can also see this for R6 objects. Example code: en = new.env(parent = asNamespace("mlr3misc"))
Test = R6::R6Class(
"Test",
parent_env = en,
public = list(
base = function() stop("base"),
misc = function() stopf("misc")
)
)
capture_calls = function(object) {
list(
base = conditionCall(tryCatch(object$base(), error = identity)),
misc = conditionCall(tryCatch(object$misc(), error = identity))
)
}
capture_calls(Test$new())
leanify_r6(Test, en)
capture_calls(Test$new())Old New |
|
@sebffischer you removed showing the 'call' in |
|
We wanted this here in mlr3pipelines.