Skip to content

Commit 15cdc41

Browse files
committed
Error descriptions
1 parent f0349b5 commit 15cdc41

File tree

1 file changed

+35
-1
lines changed

1 file changed

+35
-1
lines changed

Sources/AX/AXError.swift

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public enum AXError: Error {
2727
case failure
2828
/// An illegal argument was passed to the function.
2929
case illegalArgument
30-
/// The AXUIElementRef passed to the function is invalid.
30+
/// The UIElement passed to the function is invalid.
3131
case invalidUIElement
3232
/// The Observer passed to the function is not a valid observer.
3333
case invalidUIElementObserver
@@ -115,6 +115,40 @@ public enum AXError: Error {
115115
self = .failure
116116
}
117117
}
118+
public var localizedDescription: String {
119+
switch self {
120+
case .actionUnsupported:
121+
return "AX.AXError.actionUnsupported - The action is not supported by the UIElement."
122+
case .apiDisabled:
123+
return "AX.AXError.apiDisabled - The accessibility API is disabled."
124+
case .attributeUnsupported:
125+
return "AX.AXError.attributeUnsupported - The attribute is not supported by the UIElement."
126+
case .parameterizedAttributeUnsupported:
127+
return "AX.AXError.parameterizedAttributeUnsupported - The parameterized attribute is not supported by the UIElement."
128+
case .cannotComplete:
129+
return "AX.AXError.cannotComplete - The function cannot complete because messaging failed in some way or because the application with which the function is communicating is busy or unresponsive."
130+
case .failure:
131+
return "AX.AXError.failure - A system error occurred, such as the failure to allocate an object."
132+
case .illegalArgument:
133+
return "AX.AXError.illegalArgument - An illegal argument was passed to the function."
134+
case .invalidUIElement:
135+
return "AX.AXError.invalidUIElement - The UIElement passed to the function is invalid."
136+
case .invalidUIElementObserver:
137+
return "AX.AXError.invalidUIElementObserver - The Observer passed to the function is not a valid observer."
138+
case .notEnoughPrecision:
139+
return "AX.AXError.notEnoughPrecision - Not enough precision."
140+
case .notificationAlreadyRegistered:
141+
return "AX.AXError.notificationAlreadyRegistered - This notification has already been registered."
142+
case .notificationUnsupported:
143+
return "AX.AXError.notificationUnsupported - The notification is not supported by the UIElement"
144+
case .notImplemented:
145+
return "AX.AXError.notImplemented - Indicates that the function or method is not implemented (this can be returned if a process does not support the accessibility API)."
146+
case .notificationNotRegistered:
147+
return "AX.AXError.notificationNotRegistered"
148+
case .noValue:
149+
return "AX.AXError.noValue - The requested value or UIElement does not exist."
150+
}
151+
}
118152
}
119153

120154
@available(macOS 10.2, *)

0 commit comments

Comments
 (0)