How to add information about the line that caused the error?

I would like to use a function that exports errors to a .txt file. So far, I:

error.function <- function() { cat(geterrmessage(), file="c:/bla.txt", append=TRUE) } 

then

 options("error"=error.function) 

However, this only gives me error without the corresponding line number. May I ask for help to extend the error.function function with information about the line number (my script in Rstudio starts at line 1 and goes up to line 2500?

+5
source share

All Articles