Closed ngreifer closed 2 years ago
Thanks @ngreifer - we'll look into
This was a good idea - I've switched to rlang::abort()
and set the call value so that now the code tells the user where the error is conditional on it being informative
library(chk)
chk_string(1)
#> Error:
#> ! `1` must be a string (non-missing character scalar).
fun <- function(x) chk_string(x)
fun(1)
#> Error in `fun()`:
#> ! `x` must be a string (non-missing character scalar).
Created on 2022-08-25 by the reprex package (v2.0.1)
This is still a bit of a problem with all the chk_
functions, which still just display the location of the error, even if that is in a non-user-visible function. Also, in err()
, the default to call
is caller_call(3)
which seems arbitrary (i.e., is err()
supposed to be used 3 function calls deep?). Not sure what a sensible default is, but I don't know if 3 is it.
This old thread has been automatically locked. If you think you have found something related to this, please open a new issue and link to this old issue if necessary.
When an error is thrown (i.e., as the result of
err()
orchk_
function), the error thrown always saysThe user should not see
err()
and likely doesn't know what it is, so that part of the error message is confusing and unnecessary. It doesn't actually tell the user where the error is; it appears to be in a functionerr()
that they did not call. It would be great iferr()
would not display the function call unless requested, similar torlang::abort()
doesn't orstop(., call. = FALSE)
. This is due to usingrlang::exec()
in theerr()
call rather than callingrlang::abort()
directly; for some reason usingexec()
triggerscall
to be found and supplied. Thanks!