<!--
{
  "documentType" : "article",
  "framework" : "Foundation",
  "identifier" : "/documentation/Foundation/errors-and-exceptions",
  "metadataVersion" : "0.1.0",
  "role" : "collectionGroup",
  "title" : "Errors and Exceptions"
}
-->

# Errors and Exceptions

Respond to problem situations in your interactions with APIs, and fine-tune your app for better debugging.

## Topics

### User-Relevant Errors

  <doc://com.apple.documentation/documentation/Swift/Error>

[`NSError`](/documentation/Foundation/NSError)

Information about an error condition including a domain, a domain-specific error code, and application-specific information.

[`LocalizedError`](/documentation/Foundation/LocalizedError)

A specialized error that provides localized messages describing the error and why it occurred.

[`RecoverableError`](/documentation/Foundation/RecoverableError)

A specialized error that may be recoverable by presenting several potential recovery options to the user.

[`CustomNSError`](/documentation/Foundation/CustomNSError)

A specialized error that provides a domain, error code, and user-info dictionary.

### Assertions

[`NSAssertionHandler`](/documentation/Foundation/NSAssertionHandler)

An object that logs an assertion to the console.

[`NSAssert`](/documentation/Foundation/NSAssert)

Generates an assertion if a given condition is false.

[`NSAssert1`](/documentation/Foundation/NSAssert1)

Generates an assertion if a given condition is false.

[`NSAssert2`](/documentation/Foundation/NSAssert2)

Generates an assertion if a given condition is false.

[`NSAssert3`](/documentation/Foundation/NSAssert3)

Generates an assertion if a given condition is false.

[`NSAssert4`](/documentation/Foundation/NSAssert4)

Generates an assertion if a given condition is false.

[`NSAssert5`](/documentation/Foundation/NSAssert5)

Generates an assertion if a given condition is false.

[`NSCAssert`](/documentation/Foundation/NSCAssert)

Generates an assertion if the given condition is false.

[`NSCAssert1`](/documentation/Foundation/NSCAssert1)

Generates an assertion if a given condition is false.

[`NSCAssert2`](/documentation/Foundation/NSCAssert2)

Generates an assertion if a given condition is false.

[`NSCAssert3`](/documentation/Foundation/NSCAssert3)

Generates an assertion if a given condition is false.

[`NSCAssert4`](/documentation/Foundation/NSCAssert4)

Generates an assertion if a given condition is false.

[`NSCAssert5`](/documentation/Foundation/NSCAssert5)

Generates an assertion if a given condition is false.

[`NSCParameterAssert`](/documentation/Foundation/NSCParameterAssert)

Evaluates the specified parameter.

[`NSParameterAssert`](/documentation/Foundation/NSParameterAssert)

Validates the specified parameter.

### Exceptions

[`NSException`](/documentation/Foundation/NSException)

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

### Diagnostics and Debugging

[`NSLog`](/documentation/Foundation/NSLog)

Logs an error message to the Apple System Log facility.

[`NSLogv(_:_:)`](/documentation/Foundation/NSLogv(_:_:))

Logs an error message to the Apple System Log facility.

[`NSLog(_:_:)`](/documentation/Foundation/NSLog(_:_:))

Logs an error message to the Apple System Log facility.

[`NSDeallocateZombies`](/documentation/Foundation/NSDeallocateZombies)

A global variable that determines whether or not the memory of zombie objects is deallocated.

[`NSDebugEnabled`](/documentation/Foundation/NSDebugEnabled)

A global variable that can be used to enable debug behavior in your app, such as extra logging.

[`NSZombieEnabled`](/documentation/Foundation/NSZombieEnabled)

A global variable related to zombie objects that in practice has no effect.

[`NSKeepAllocationStatistics`](/documentation/Foundation/NSKeepAllocationStatistics)

A no-longer-used global variable related to keeping statistics.



---

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)