fetch Or Null
Executes the given block and returns its result, or null if an exception is thrown.
Use this for graceful degradation when fetching supplementary data that can safely be omitted on failure. For example, when accessing GRT fields that may throw due to policy check errors, this allows returning null instead of propagating the exception.
CancellationException is always rethrown to preserve structured concurrency.
Example:
val countryOfResidence: String? = fetchOrNull {
viewer?.getUser()?.getOwner()?.getCountryForTax()?.getCountryOfResidence()
}Content copied to clipboard