Reputation: 797
I am new to R language. I gone through exception handling frame work tutorials, but i can't able to find any options to print entire error stack trace , below is my code
getData<-function(a,b){
c=NULL
tryCatch({
c=a+b
},error=function(cond){
fileConn<-file("output.txt")
writeLines(as.character(cond), fileConn)
close(fileConn)
}
)
return(c)
}
In above code if any exception happens i need to write in a file by mentioning the line number where the error occurred, let's say i am getting input to the method like below
getData(1,"vv")
It will throw exception like below, but I am not able to find the exact line number where error occurred , please help me to resolve this issue
Error in a + b: non-numeric argument to binary operator
Upvotes: 2
Views: 141