---
title: NSCoder.DecodingFailurePolicy.setErrorAndReturn
framework: foundation
role: symbol
role_heading: Case
path: foundation/nscoder/decodingfailurepolicy-swift.enum/seterrorandreturn
---

# NSCoder.DecodingFailurePolicy.setErrorAndReturn

A failure policy that directs the coder to capture the failure as an error object.

## Declaration

```swift
case setErrorAndReturn
```

## Discussion

Discussion On decode failure, the NSCoder will capture the failure as an NSError, and prevent further decodes (by returning 0 / nil equivalent as appropriate). Use this policy if you know that all encoded objects use failWithError(_:) to communicate decode failures and don’t raise exceptions for error propagation.

## See Also

### Failure Policies

- [NSCoder.DecodingFailurePolicy.raiseException](foundation/nscoder/decodingfailurepolicy-swift.enum/raiseexception.md)
