"t = 1 node = sickness2\\nt = 1 node = sickness1"
"helpful error message node processing working"
"An error occured when processing node 'car_crash'"
" at time t = 100. The message was:\nError in ("
"function (data, sim_time, base_p) : Error at"
"helpful error message adding node to data working"
"An error occured when trying to add the output of "
"node 'custom_nonsense' at time t = 100 to the "
"current data. The message was:\nError in "
"`[<-.data.table`(`*tmp*`, , name, value = list(20, "
"12)): Supplied 2 items to be assigned to 10 items "
"of column 'custom_nonsense'. If you wish to "
"'recycle' the RHS please use rep() to make this "
"helpful error message when processing tx_transform_fun"
"An error occured when calling the tx_transform() "
"function at t = 1. The message was:\nError in "
"An error occured when interpreting the formula of "
"node 'B'. The message was:\nError: Error: column(s) not "
"found: [A, C]\nThis error may occur when one of the terms "
"in the generated data.\n Please check whether all terms "
"in your supplied formula occur in the data generated up "
"to this point.\n The variables currently available in "

Error: An error occured when interpreting the formula of node 'B'. The message was:
Error: Error in `[.data.table`(mod_mat, , args$parents, with = FALSE): column(s) not found: [A, C]
This error may occur when one of the terms in a supplied formula does not match any variables in the generated data.
 Please check whether all terms in your supplied formula occur in the data generated up to this point.
 The variables currently available in data are:
(Intercept), ATRUE

mod_bmi <- lm(bmi ~ sex + age, data=sim_dat)
child_nodes <- list(list(parents=c("sex", "age", "income"),
sim_dat <- sim_from_dag(n_sim=20, dag=dag, sort_dag=TRUE)
test_that("accepts nodes directly passed in type", {
node("A", type=rbernoulli, p=0.4, output="numeric") +
node("B", type=node_gaussian, formula=~ -1 + A*3, error=2) +
test_that("helpful error message root nodes", {
paste0("An error occured when processing root node 'B'. ",
"The message was:\nError in (function (n) : ",
test_that("helpful error message child nodes", {
node_custom <- function(data, parents) {
paste0("An error occured when processing node 'B'. ",
"(function (data, parents) : failed instantly"),
node("B", type="gaussian", formula= ~ -1 + A*2 + C*3)

"An error occured when processing root node 'B'. "
"The message was:\nError in (function (n) : "
"An error occured when processing node 'B'. "
"(function (data, parents) : failed instantly"