Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mapping IOKit IOReturn error code to String

When I get error 0x10, I want to be able to make sense of that error code. Looking up IOReturn.h and mach/error.h is not particularly convenient. I was lost when I got 0x22 error code. This is really silly question but is there a function like error2String which can map IOReturn error code to String that describes the error ?

like image 609
blacklife Avatar asked Dec 10 '25 22:12

blacklife


1 Answers

You can use the mach_error_string standard foundation function to do this.

Eg. in Swift:

func krToString (_ kr: kern_return_t) -> String {
    if let cStr = mach_error_string(kr) {
        return String (cString: cStr)
    } else {
        return "Unknown kernel error \(kr)"
    }
}
like image 160
Colin Wilson Avatar answered Dec 12 '25 14:12

Colin Wilson