An error that indicates a problem occurred while performing an app intent.
## Overview
When your app intent encounters an error during execution, throw an `AppIntentError`
to communicate structured failure information to the system. Apple Intelligence, Siri,
and Shortcuts use this information to determine the appropriate response — such as
prompting a person, retrying the operation, or reporting the failure.
You can create an `AppIntentError` in several ways:
- term Predefined errors: Use values from ``AppIntentError/PermissionRequired``,
``AppIntentError/UserActionRequired``, or ``AppIntentError/Unrecoverable`` for
common failure scenarios that the system already knows how to handle.
- term Wrapping a custom error: If your error type conforms to
<doc://com.apple.documentation/documentation/foundation/CustomLocalizedStringResourceConvertible>,
pass it to ``init(wrapping:)`` to provide a localized description.
- term Description string: Create an error with a localized description directly from a
<doc://com.apple.documentation/documentation/foundation/LocalizedStringResource>
and pass it to ``init(description:)``.
The recommended approach for most apps is to define an error enumeration that conforms to
``CustomLocalizedStringResourceConvertible` and throw it from your intent's ``AppIntent/perform()``
method. The framework automatically wraps conforming errors into an `AppIntentError` with
the localized description you provide.
Creates an error from a predefined error with a custom localized description.
Use this initializer to create one of the predefined ``AppIntentError`` values with a custom message specific to your app's context.
See the predefined static properties on ``AppIntentError`` for the list of accepted values.
Passing any other ``AppIntentError`` value triggers a runtime failure via `fatalError()`.
- Parameters:
- predefinedError: The predefined error to throw.
- description: A custom localized description of the error.
Creates an error with a localized description.
- Parameters:
- description: A localized description of the error.
get · iOS 17.0+
description
TypeScript
get description(): string
Swift declaration
var description: String { get }
A textual representation of this instance.
Calling this property directly is discouraged. Instead, convert an
instance of any type to a string by using the `String(describing:)`
initializer. This initializer works with any type, and uses the custom
`description` property for types that conform to
`CustomStringConvertible`:
struct Point: CustomStringConvertible {
let x: Int, y: Int
var description: String {
return "(\(x), \(y))"
}
}
let p = Point(x: 21, y: 30)
let s = String(describing: p)
print(s)
// Prints "(21, 30)"
The conversion of `p` to a string in the assignment to `s` uses the
`Point` type's `description` property.
get · iOS 16.0+
restartPerform
TypeScript
static get restartPerform(): AppIntentError
Swift declaration
static var restartPerform: AppIntentError { get }
get · iOS 18.0+
localizedStringResource
TypeScript
get localizedStringResource(): _Foundation_LocalizedStringResource
Swift declaration
var localizedStringResource: LocalizedStringResource { get }
A localizable string that describes the error.
Skipped declarations
2 declarations were excluded from these bindings. Each reason comes from the generator or the iOS SDK compiler.