Closed edgBR closed 2 years ago
Well,
It seems that finally I managed to do what I wanted, a small PoC:
library(vroom)
dataImport <- function(input_path, file_name) {
data_out <- tryCatch(
vroom(file = paste(input_path, file_name, sep="/")),
error = function(e) {e},
warning = function(w) {w}
)
if(inherits(data_out, "error")){
log_error(data_out$message)
} else if(inherits(data_out, "warning")){
log_warn(data_out$message)
} else {
log_info("Reading {file_name} was successful")
}
return(data_out)
}
However it would be nice that a log_error() automatically stops my code.
Would the use of logger::log_failure(e)
be a solution for your case?
Dear colleagues,
Following the best practices of our Software developer colleagues the data scientist team where I am working for have started to implement trycatch + standard logging to debug our containerized code faster.
I have been experimenting with logger and so far the experience is awesome!. However it is a bit tricky to combine with trycatch. For example:
When running this (which btw is wrong code) I get the following error:
When running with logger:
I get a very cryptic error.
I am misunderstanding the usage of logger in this situations? Should I be using trycatchlog instead? Is this a feature that is not supported yet?
BR /Edgar