def handle_sec_error(error, exception_class=None):
if error == <NUM_LIT:0>:<EOL><INDENT>return<EOL><DEDENT>if error in set([SecurityConst.errSSLClosedNoNotify, SecurityConst.errSSLClosedAbort]):<EOL><INDENT>raise TLSDisconnectError('<STR_LIT>')<EOL><DEDENT>if error == SecurityConst.errSSLClosedGraceful:<EOL><INDENT>raise TLSGracefulDisconnectError('<STR_LIT>')<EOL><DEDENT>cf_error_string = Security.SecCopyErrorMessageString(error, null())<EOL>output = CFHelpers.cf_string_to_unicode(cf_error_string)<EOL>CoreFoundation.CFRelease(cf_error_string)<EOL>if output is None or output == '<STR_LIT>':<EOL><INDENT>output = '<STR_LIT>' % error<EOL><DEDENT>if exception_class is None:<EOL><INDENT>exception_class = OSError<EOL><DEDENT>raise exception_class(output)<EOL>
Checks a Security OSStatus error code and throws an exception if there is an
error to report

:param error:
    An OSStatus

:param exception_class:
    The exception class to use for the exception if an error occurred

:raises:
    OSError - when the OSStatus contains an error