---
title: "NSSetUncaughtExceptionHandler(_:)"
framework: foundation
role: symbol
role_heading: Function
path: "foundation/nssetuncaughtexceptionhandler(_:)"
---

# NSSetUncaughtExceptionHandler(_:)

Changes the top-level error handler.

## Declaration

```swift
func NSSetUncaughtExceptionHandler(_: ((NSException) -> Void)?)
```

## Discussion

Discussion Sets the top-level error-handling function where you can perform last-minute logging before the program terminates.

## See Also

### Related Documentation

- [NSGetUncaughtExceptionHandler()](foundation/nsgetuncaughtexceptionhandler().md)
- [reportException(_:)](appkit/nsapplication/reportexception(_:).md)

### Functions

- [NSGetUncaughtExceptionHandler()](foundation/nsgetuncaughtexceptionhandler().md)
