From Xojo Documentation
Jump to: navigation, search

Class (inherits from RuntimeException)

A method of the KeyChain or KeyChainItem classes failed. See the error code returned by KeyChainException to diagnose the problem.



The following tables shows the values of ErrorNumber and the associated text returned in the Message property.

Error Number Message
-128 User Cancelled.
-25291 Key Chain not available.
-25292 Key Chain read only.
-25293 Key Chain Authorization failed.
-25294 No such Key Chain.
-25295 Invalid Key Chain.
-25296 Duplicate Key Chain.
-25797 Key Chain Duplicate Callback.
-25298 Key Chain Invalid Callback.
-25299 Key Chain Duplicate Item.
-25300 Key Chain Item Not Found.
-25301 Key Chain Buffer Too Small.
-25302 Key Chain Data Too Large.
-25303 Key Chain No Such Attribute.
-25304 Key Chain Invalid Item Reference.
-25305 Key Chain Invalid Search Reference.
-25306 Key Chain No Such Class.
-25307 No Default Key Chain.
-25308 Key Chain Interaction Not Allowed.
-25309 Key Chain Read Only Attribute.
-25310 Wrong Key Chain Version.
-25311 Key Chain Key Size Not Allowed.
-25312 Key Chain No Storage Module.
-25313 Key Chain No Certificate Module.
-25314 Key Chain No Policy Module.
-25315 Key Chain Interaction Required.
-25316 Key Chain Data Not Available.
-25317 Key Chain Data Not Modifiable.
-25318 Key Chain Create Chain Failed.


The following example displays a message box if, for example, you try to create more than one KeyChainItem for the same application.

Dim NewItem As KeyChainItem
If System.KeyChainCount > 0 Then
newItem = New KeyChainItem
// Indicate the name of the application
newItem.ServiceName = "MyApplication"

// Create a new keychain item for the application and assign the password
System.KeyChain.AddPassword(newItem, "SecretPassword")
MsgBox("You don't have a key chain.")
End If
Exception err As KeyChainException
MsgBox(err.Message + ". Error Code: " + Str(err.errorNumber))

The following example uses an Exception block to display a message box if the application specified by ServiceName does not have a KeyChainItem.

Dim itemToFind As KeyChainItem
Dim password As String

itemToFind = New KeyChainItem

// Indicate the name of the application whose keychain item you wish to find
itemToFind.ServiceName = "MyApplication"

// get application's password from the system keychain
password = System.KeyChain.FindPassword(itemToFind)
MsgBox("The password for this item is: " + password)

Exception err As KeyChainException
MsgBox("Can't find item: " + err.Message)

See Also

KeyChain, KeyChainItem, RuntimeException classes; System module.

Personal tools

Starting Out
Dig Deeper
More Help