Skip to contents

Provides a structured restart mechanism to rerun the quality control (QC) function with an alternative function during the execution of read_and_qc_field. This allows for a flexible error recovery strategy when the initial QC function fails or is deemed inadequate.

Usage

seasonder_rerun_qc_with_fun(cond, qc_fun)

Arguments

cond

The condition object captured during the execution of the read_and_qc_field function.

qc_fun

An alternate quality control function to apply. This function should accept the value from the field as its sole argument and return a QC-applied value.

Value

The value returned by the alternate quality control function.

Details

This function is meant to be used within custom condition handlers for the read_and_qc_field function.

Examples

# Example (expected to error due to missing restart):
val <- try(
  seasonder_rerun_qc_with_fun(
    list(seasonder_value = 42),
    function(x) x * 2
  ),
  silent = TRUE
)
print(val)
#> [1] "Error in invokeRestart(\"seasonder_rerun_qc_with_fun\", cond, qc_fun) : \n  no 'restart' 'seasonder_rerun_qc_with_fun' found\n"
#> attr(,"class")
#> [1] "try-error"
#> attr(,"condition")
#> <simpleError in invokeRestart("seasonder_rerun_qc_with_fun", cond, qc_fun): no 'restart' 'seasonder_rerun_qc_with_fun' found>