module Sec

The module to which FFI attaches constants

Constants

SEC_KEY_IMPORT_EXPORT_PARAMS_VERSION

Public Class Methods

check_osstatus(result) click to toggle source

If the result is non-zero raises an exception.

The exception will have the result code as well as a human readable description

@param [Integer] result the status code to check @raise [Keychain::Error] is the result is non zero

# File lib/keychain/sec.rb, line 177
def self.check_osstatus result
  if result != 0
    case result
    when Sec.enum_value(:errSecDuplicateItem)
      raise Keychain::DuplicateItemError.new(result)
    when Sec.enum_value(:errCancelled)
      raise Keychain::UserCancelledError.new(result)
    when Sec.enum_value(:errSecAuthFailed)
      raise Keychain::AuthFailedError.new(result)
    when Sec.enum_value(:errSecNoSuchKeychain)
      raise Keychain::NoSuchKeychainError.new(result)
    when Sec.enum_value(:errSecInteractionNotAllowed)
      raise Keychain::InteractionNotAllowedError.new(result)
    else
      raise Keychain::Error.new(result)
    end
  end
end