SpotlightException

From Xojo Documentation

Revision as of 23:11, 27 February 2022 by Gperlman (talk | contribs) (Sample Code)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
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.