SpotlightException

From Xojo Documentation

You are currently browsing the old Xojo documentation site. Please visit the new Xojo documentation site!

Class (inherits from RuntimeException)

Used to handle exceptions related to Spotlight queries, such as a invalid query passed to the Query property of a SpotlightQuery control.

Properties
ErrorNumber Message
Methods
Stack StackFrames

Sample Code

This code adds an Exception block to a button Action event handler in case of an spotlight query error.

Var query As New SpotlightQuery("kMDItemContentTypeTree == 'public.audio'")
query.Synchronous = True
query.Run
For i As Integer = 0 To query.Count - 1
ListBox1.AddRow(query.Item(i).File.DisplayName)
ListBox1.CellTextAt(ListBox1.LastAddedRowIndex, 1) = query.Item(i).File.NativePath
Next

Exception e As SpotlightException
MessageBox("A Spotlight error occurred.")

See Also

Exception, Try statements, RuntimeException, SpotlightItem, SpotlightQuery classes.