All Downloads are FREE. Search and download functionalities are using the official Maven repository.

iosMain.net.iriscan.sdk.utils.ErrorUtils.kt Maven / Gradle / Ivy

There is a newer version: 0.6.0
Show newest version
package net.iriscan.sdk.utils

import kotlinx.cinterop.*
import platform.Foundation.NSError

/**
 * @author Slava Gornostal
 */
internal fun  throwError(block: (errorPointer: CPointer>) -> T): T =
    memScoped {
        val errorPointer: CPointer> = alloc>().ptr
        val result: T = block(errorPointer)
        val error: NSError? = errorPointer.pointed.value
        if (error != null) {
            throw NSErrorException(error)
        } else {
            return result
        }
    }

class NSErrorException(nsError: NSError) : Exception(nsError.toString())




© 2015 - 2024 Weber Informatics LLC | Privacy Policy