Learn R Programming

SafeMapper (version 1.0.0)

s_safely: Safe Safely - Wrap Function to Capture Errors

Description

Drop-in replacement for purrr::safely that captures errors and returns them in a structured format.

Usage

s_safely(.f, otherwise = NULL, quiet = TRUE)

Value

A function that returns a list with 'result' and 'error' components.

Arguments

.f

A function to wrap for safe execution.

otherwise

Default return value when an error occurs.

quiet

Logical. Hide errors from console if TRUE.

Examples

Run this code
safe_log <- s_safely(log)
safe_log(10) # Returns list(result = 2.30, error = NULL)
safe_log("a") # Returns list(result = NULL, error = )

Run the code above in your browser using DataLab