DecodingError

enum DecodingError

An error that occurs during the decoding of a value.

Inheritance Error View Protocol Hierarchy →
Nested Types DecodingError.Context
Import import Swift

Cases

case typeMismatch(Any.Type, DecodingError.Context)

An indication that a value of the given type could not be decoded because it did not match the type of what was found in the encoded payload.

As associated values, this case contains the attempted type and context for debugging.

Declaration

case valueNotFound(Any.Type, DecodingError.Context)

An indication that a non-optional value of the given type was expected, but a null value was found.

As associated values, this case contains the attempted type and context for debugging.

Declaration

case keyNotFound(CodingKey, DecodingError.Context)

An indication that a keyed decoding container was asked for an entry for the given key, but did not contain one.

As associated values, this case contains the attempted key and context for debugging.

Declaration

case dataCorrupted(DecodingError.Context)

An indication that the data is corrupted or otherwise invalid.

As an associated value, this case contains the context for debugging.

Declaration

Static Methods

static func dataCorruptedError(forKey:in:debugDescription:)

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

The coding path for the returned error is constructed by appending the given key to the given container's coding path.

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

Returns: A new .dataCorrupted error with the given information.

Declaration

static func dataCorruptedError<C>(forKey key: C.Key, in container: C, debugDescription: String) -> DecodingError where C : KeyedDecodingContainerProtocol
static func dataCorruptedError(in: SingleValueDecodingContainer, debugDescription: String)

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

The coding path for the returned error is the given container's coding path.

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

Returns: A new .dataCorrupted error with the given information.

Declaration

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

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

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.

Returns: A new .dataCorrupted error with the given information.

Declaration

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

Conditionally Inherited Items

The initializers, methods, and properties listed below may be available on this type under certain conditions (such as methods that are available on Array when its elements are Equatable) or may not ever be available if that determination is beyond SwiftDoc.org's capabilities. Please open an issue on GitHub if you see something out of place!

Where RawValue : SignedInteger

Where RawValue : UnsignedInteger