epiverse-trace / linelist

R package for handling linelist data
https://epiverse-trace.github.io/linelist/
Other
8 stars 4 forks source link

Add custom class to tag loss conditions #109

Closed Bisaloo closed 6 months ago

Bisaloo commented 6 months ago

New feature

Linelist tagged variable loss condition are not classed.

Customs classes (linelist_error and linelist_warning) are added to conditions raised in case of tagged variable loss. This enables advanced condition handling, as illustrated in the following reprex:

warning_counter <- 0

withCallingHandlers({
  x <- linelist::make_linelist(cars, date_onset = "dist", age = "speed")
  x <- x[, -1]
  x <- x[, -1]
  warning("This is not a linelist warning", call. = FALSE)
}, linelist_warning = function(w) {
  warning_counter <<- warning_counter + 1
})
#> Warning: The following tags have lost their variable:
#>  age:speed
#> Warning: The following tags have lost their variable:
#>  date_onset:dist
#> Warning: This is not a linelist warning

warning("This pipeline generated ", warning_counter, " linelist warnings.")
#> Warning: This pipeline generated 2 linelist warnings.

No

Fix #90