# WARNING - Generated by {fusen} from dev/flat_kwb_simulate_inflow.Rmd: do not edit by hand # nolint: line_length_linter.

#' Get exposure value or stop
#' 
#' This function does the same thing as kwb.utils::exposure_value_or_stop(),
#' but it is bundled with *ambre* to avoid a hard dependency on the
#' unmaintained package.
#' 
#' Description
#' @param config list config
#' @param name character name of the column
#' @return value
#' @references
#'   Sonnenberg H (2024). kwb.utils: General Utility Functions Developed at KWB. R package version 0.15.0
#'   URL: \url{https://github.com/kwb-r/kwb.utils}
#'   (MIT Licence)
#' @export
#' @examples
#' get_exposure_value_or_stop(config_ambre, "number_of_exposures")
get_exposure_value_or_stop <- function(config, name)
{
  # HARD CODED: "name" MUST be of type value!
  value <- config$exposure$value[config$exposure$name == name]

  if (is.na(value)) {
    stop(sprintf(get_stop_text("must_be_value"), name), call. = FALSE)
  }
  
  value
}
