<!--
{
  "availability" : [
    "macOS: -"
  ],
  "documentType" : "symbol",
  "framework" : "AppKit",
  "identifier" : "/documentation/AppKit/NSAlert/init(error:)",
  "metadataVersion" : "0.1.0",
  "role" : "Initializer",
  "symbol" : {
    "kind" : "Initializer",
    "modules" : [
      "AppKit"
    ],
    "preciseIdentifier" : "c:objc(cs)NSAlert(cm)alertWithError:"
  },
  "title" : "init(error:)"
}
-->

# init(error:)

Returns an alert initialized from information in an error object.

```
init(error: any Error)
```

## Parameters

`error`

Error information to display.

## Return Value

An initialized alert.

## Discussion

The `NSAlert` class extracts the localized error description, recovery suggestion, and recovery options from the `error` parameter and uses them as the alert’s message text, informative text, and button titles, respectively.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)