safeCall
safeCall<
T>(fn,fallback,debug?,label?):Promise<T>
Defined in: src/policies/sdk/helpers.ts:107
Execute an async operation with graceful error handling.
Designed for store-backed policies (cache, rate-limit, circuit-breaker)
where a store failure should degrade gracefully - not crash the request.
Returns the fallback value if fn throws.
Type Parameters
Section titled “Type Parameters”T
Parameters
Section titled “Parameters”() => Promise<T>
The async operation to attempt.
fallback
Section titled “fallback”T
Value to return if fn throws.
debug?
Section titled “debug?”Optional debug logger for error reporting.
label?
Section titled “label?”string
Optional label for the debug message (e.g. "store.get()").
Returns
Section titled “Returns”Promise<T>
The result of fn, or fallback on error.
Example
Section titled “Example”const cached = await safeCall( () => store.get(key), null, debug, "store.get()",);