SpotlightException

From Xojo Documentation

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 Reason fa-lock-32.png
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.CellValueAt(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.