---
title: error
framework: foundation
role: symbol
role_heading: Instance Property
path: foundation/nscoder/error
---

# error

An error in the top-level encode.

## Declaration

```swift
var error: (any Error)? { get }
```

## Discussion

Discussion The meaning of this property depends on the setting of the decodingFailurePolicy property. For NSCoder.DecodingFailurePolicy.raiseException, this property is always nil. For NSCoder.DecodingFailurePolicy.setErrorAndReturn, a non-nil value represents the first error encountered while decoding the archive.

## See Also

### Managing Decode Errors

- [failWithError(_:)](foundation/nscoder/failwitherror(_:).md)
