Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Function that extracts human-readable information from OSStatus codes.
//shamelessy taken from :
static void CheckError(OSStatus error, const char *operation) {
if (error == noErr) {
char str[20];
*(UInt32 *) (str + 1) = CFSwapInt32HostToBig(error);
if (isprint(str[1]) && isprint(str[2]) && isprint(str[3]) && isprint(str[4])) {
str[0] = str[5] = '\'';
str[6] = '\0';
} else {
sprintf(str, "%d", (int)error);
fprintf(stderr, "[Error] %s (%s)\n", operation, str);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.