---
title: NSException
framework: foundation
role: symbol
role_heading: Class
path: foundation/nsexception
---

# NSException

An object that represents a special condition that interrupts the normal flow of program execution.

## Declaration

```swift
class NSException
```

## Overview

Overview Use NSException to implement exception handling. An exception is a special condition that interrupts the normal flow of program execution. Each application can interrupt the program for different reasons. For example, one application might interpret saving a file in a directory that is write-protected as an exception. In this sense, the exception is equivalent to an error. Another application might interpret the user’s key-press (for example, Control-C) as an exception: an indication that a long-running process should abort.

## Topics

### Creating and Raising an NSException Object

- [raise(_:format:arguments:)](foundation/nsexception/raise(_:format:arguments:).md)
- [init(name:reason:userInfo:)](foundation/nsexception/init(name:reason:userinfo:).md)
- [raise()](foundation/nsexception/raise().md)

### Querying an NSException Object

- [name](foundation/nsexception/name-swift.property.md)
- [reason](foundation/nsexception/reason-swift.property.md)
- [userInfo](foundation/nsexception/userinfo-swift.property.md)

### Getting Exception Stack Frames

- [callStackReturnAddresses](foundation/nsexception/callstackreturnaddresses.md)
- [callStackSymbols](foundation/nsexception/callstacksymbols.md)

### Related Types

- [NSUncaughtExceptionHandler](foundation/nsuncaughtexceptionhandler.md)
- [NSExceptionName](foundation/nsexceptionname.md)

### Functions

- [NSGetUncaughtExceptionHandler()](foundation/nsgetuncaughtexceptionhandler().md)
- [NSSetUncaughtExceptionHandler(_:)](foundation/nssetuncaughtexceptionhandler(_:).md)

### Initializers

- [init(coder:)](foundation/nsexception/init(coder:).md)

## Relationships

### Inherits From

- [NSObject](objectivec/nsobject-swift.class.md)

### Conforms To

- [CVarArg](swift/cvararg.md)
- [CustomDebugStringConvertible](swift/customdebugstringconvertible.md)
- [CustomStringConvertible](swift/customstringconvertible.md)
- [Equatable](swift/equatable.md)
- [Hashable](swift/hashable.md)
- [NSCoding](foundation/nscoding.md)
- [NSCopying](foundation/nscopying.md)
- [NSObjectProtocol](objectivec/nsobjectprotocol.md)
- [NSSecureCoding](foundation/nssecurecoding.md)
