---
title: "init(name:reason:userInfo:)"
framework: foundation
role: symbol
role_heading: Initializer
path: "foundation/nsexception/init(name:reason:userinfo:)"
---

# init(name:reason:userInfo:)

Initializes and returns a newly allocated exception object.

## Declaration

```swift
init(name aName: NSExceptionName, reason aReason: String?, userInfo aUserInfo: [AnyHashable : Any]? = nil)
```

## Parameters

- `aName`: The name of the exception.
- `aReason`: A human-readable message string summarizing the reason for the exception.
- `aUserInfo`: A dictionary containing user-defined information relating to the exception

## Return Value

Return Value The created NSException object or nil if the object couldn’t be created.

## Discussion

Discussion This is the designated initializer.

## See Also

### Creating and Raising an NSException Object

- [raise(_:format:arguments:)](foundation/nsexception/raise(_:format:arguments:).md)
- [raise()](foundation/nsexception/raise().md)
