I couldn't find any documentation on this, but during the migration of my intents I ended up using a property localizedStringResource like this:
struct MyIntent: AppIntent {
static let title: LocalizedStringResource = "Start My Intent"
func perform() async throws -> some IntentResult {
if !doSomething() {
throw MyIntentError.message("Hello, I'm an error!")
}
return .result(dialog: IntentDialog("My answer"))
}
func doSomething() -> Bool {
return false
}
}
enum MyIntentError: Swift.Error, CustomLocalizedStringResourceConvertible {
case general
case message(_ message: String)
var localizedStringResource: LocalizedStringResource {
switch self {
case let .message(message): return "Error: \(message)"
case .general: return "My general error"
}
}
}
Topic:
App & System Services
SubTopic:
Core OS
Tags: