<!--
{
  "availability" : [
    "iOS: 8.0.0 -",
    "iPadOS: 8.0.0 -",
    "macCatalyst: 13.0.0 -",
    "macOS: 10.10.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 2.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Swift",
  "identifier" : "/documentation/Swift/DecodingError/dataCorruptedError(in:debugDescription:)-5on9z",
  "metadataVersion" : "0.1.0",
  "role" : "Type Method",
  "symbol" : {
    "kind" : "Type Method",
    "modules" : [
      "Swift"
    ],
    "preciseIdentifier" : "s:s13DecodingErrorO013dataCorruptedB02in16debugDescriptionABs07UnkeyedA9Container_p_SStFZ"
  },
  "title" : "dataCorruptedError(in:debugDescription:)"
}
-->

# dataCorruptedError(in:debugDescription:)

Returns a new `.dataCorrupted` error using a constructed coding path and
the given debug description.

```
static func dataCorruptedError(in container: any UnkeyedDecodingContainer, debugDescription: String) -> DecodingError
```

## Return Value

A new `.dataCorrupted` error with the given information.

## Discussion

The coding path for the returned error is constructed by appending the
given container’s current index to its coding path.

- param container: The container in which the corrupted data was
  accessed.
- param debugDescription: A description of the error to aid in debugging.

---

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)