Handling Errors

Mostly in the interest of code simplification, Core Foundation functions do not follow the Mac OS OSErr convention for error reporting. However, if you rigorously test your program with the debug version of the Core Foundation library (or framework), then the possibilities for error are much reduced.

Yet there can be occasions when you want to test whether a function succeeds in its intended purpose and proceed conditionally from there. By a common-sense interpretation of returned values (and sometimes by a quick check of the reference documentation), you can usually determine the reason for failure, as in these examples:

Some Core Foundation functions return a value of type Boolean or an enum constant or some other explicitly typed indication of the reason for an outcome. Consult the Core Foundation reference documentation for an explanation of these return values.