# A successful validation:
odin::odin_validate(c("deriv(x) <- 1", "initial(x) <- 1"))
# A complete failure:
odin::odin_validate("")
# A more interesting failure
code <- c("deriv(x) <- a", "initial(x) <- 1")
res <- odin::odin_validate(code)
res
# The object 'res$error' is an 'odin_error' object:
res$error
# It contains information that might be used to display to a
# user information about the error:
unclass(res$error)
# Notes are raised in a similar way:
code <- c("deriv(x) <- 1", "initial(x) <- 1", "a <- 1")
res <- odin::odin_validate(code)
res$messages[[1]]
Run the code above in your browser using DataLab