added error checking API inline with Cocoa error reporting style