---
title: "presentError(_:)"
framework: appkit
role: symbol
role_heading: Instance Method
path: "appkit/nsdocument/presenterror(_:)"
---

# presentError(_:)

Presents an error alert to the user as a modal panel.

## Declaration

```swift
func presentError(_ error: any Error) -> Bool
```

## Parameters

- `error`: The error object encapsulating the information to present to the user.

## Return Value

Return Value true if error recovery was done; otherwise, false.

## Discussion

Discussion This method does not return until the user dismisses the alert and, if the error has recovery options and a recovery delegate, the error’s recovery delegate  is sent an attemptRecovery(fromError:optionIndex:) message. The NSDocument default implementation of this method is equivalent to that of NSResponder and treats the shared NSDocumentController as the next responder and forwards these messages to it. The default implementation of this method invokes willPresentError(_:) to give subclasses an opportunity to customize error presentation. You should not override this method but should instead override willPresentError(_:).

## See Also

### Displaying Errors to the User

- [presentError(_:modalFor:delegate:didPresent:contextInfo:)](appkit/nsdocument/presenterror(_:modalfor:delegate:didpresent:contextinfo:).md)
- [willPresentError(_:)](appkit/nsdocument/willpresenterror(_:).md)
- [willNotPresentError(_:)](appkit/nsdocument/willnotpresenterror(_:).md)
