Learn R Programming

climatehealth (version 1.0.0)

abort_model_error: Raise a model error (statistical/computational failures)

Description

Use this when statistical models fail to converge, produce singular matrices, or encounter other computational issues that aren't due to obvious user error.

Usage

abort_model_error(
  message,
  model_type = "unknown",
  ...,
  call = rlang::caller_env()
)

Value

Never returns; always raises an error.

Arguments

message

Human-readable error message

model_type

Type of model that failed (e.g., "dlnm", "glm", "meta-analysis")

...

Additional diagnostic metadata

call

The call to include in the error

Examples

Run this code
# \donttest{
tryCatch({
  stop("convergence failed")
}, error = function(e) {
  err <- tryCatch(
    abort_model_error(
    "Model failed to converge",
    model_type = "dlnm",
    original_error = conditionMessage(e)
    ),
    error = identity
  )
  inherits(err, "model_error")
})
# }

Run the code above in your browser using DataLab