...

/

Solution Review: Try Catch

Solution Review: Try Catch

In this review, we provide a detailed analysis of the solution to this problem.

Solution: Try Catch Block

Press + to interact
R
calculateLog <- function(test)
{
tryCatch(
{
cat(log(test))
},
error = function(e)
{
cat("This operation is not allowed!")
},
warning = function(w)
{
cat("This operation is not allowed!")
})
}
# Driver Code
calculateLog(10)
cat("\n")
calculateLog(-10)
cat("\n")
calculateLog("a")
cat("\n")

Explanation

We use ...