runResultCatching
inline fun <T> runResultCatching(errorPtr: CPointer<ObjCObjectVar<NSError?>>? = null, block: () -> T): Result<T>
Executes a block of code and wraps the result in a Result.
If an NSError is set in errorPtr when an exception occurs, the NSError will be converted and returned instead of the original exception. This is useful for Objective-C interop where failable initializers (e.g., initWithConfiguration:error:) return nil and set an NSError, causing a NullPointerException in Kotlin before the error can be checked manually.
Return
Result.Success with the value or Result.Failure with NSError (if set) or the original throwable
Parameters
errorPtr
Optional pointer to NSError that may be set by Objective-C code
block
The code block to execute